-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path10.09.cpp
More file actions
36 lines (32 loc) · 826 Bytes
/
10.09.cpp
File metadata and controls
36 lines (32 loc) · 826 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
27
28
29
30
31
32
33
34
35
36
#include <vector>
#include <string>
#include <algorithm>
#include <iostream>
using std::vector;
using std::string;
using std::sort;
using std::unique;
using std::cout;
using std::endl;
using std::cin;
std::ostream &print(std::ostream &os, const vector<string> &vec) {
for (const string &elem : vec) {
os << elem << ' ';
}
return os;
}
void elimDups(vector<string> &vec) {
sort(vec.begin(), vec.end());
print(cout, vec) << '\n';
vector<string>::iterator end_of_unique_elements = unique(vec.begin(), vec.end());
print(cout, vec) << '\t' << vec.size() << '\n';
vec.erase(end_of_unique_elements, vec.end());
}
int main() {
vector<string> words;
for (string temp; cin >> temp; words.push_back(temp)) ;
print(cout, words) << '\n';
elimDups(words);
print(cout, words) << '\t' << words.size() << endl;
return 0;
}