-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path10.02.cpp
More file actions
26 lines (24 loc) · 696 Bytes
/
10.02.cpp
File metadata and controls
26 lines (24 loc) · 696 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#include <algorithm>
#include <list>
#include <iostream>
#include <string>
using std::string;
using std::cout;
using std::endl;
using std::cin;
using std::list;
int main() {
list<string> words;
cout << "Enter elements to put in list: ";
for (string temp; cin >> temp; words.push_back(temp)) ;
list<string> occured;
cout << '\n';
for (const string &val : words) {
if (find(occured.cbegin(), occured.cend(), val) == occured.cend()) {
cout << val << " occurs " << count(words.cbegin(), words.cend(), val) << " times." << endl;
occured.push_back(val);
}
}
cout << "\nNumber of elements: " << words.size() << "\nNumber of unique elements: " << occured.size() << endl;
return 0;
}