-
Notifications
You must be signed in to change notification settings - Fork 0
/
uniq.cpp
52 lines (36 loc) · 959 Bytes
/
uniq.cpp
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
37
#include <iostream>
#include <string>
#include <fstream>
#include <set>
#include <sstream>
#include <vector>
using namespace std;
int main(int argc, char const* argv[]) {
string f_name = "qwerty.cool";
fstream inFile;
set<string> theSet;
string line;
inFile.open(argv[1], ios::in);
if (inFile.is_open()){
while (!(inFile.eof())){
getline(inFile, line);
if (theSet.find(line) == theSet.end()){
theSet.insert(line);
cout << line << endl;
}
}
}else{
string input;
getline(cin, input);
istringstream iss(input);
string word;
while (getline(iss, word, '\n')){
if (theSet.find(word) == theSet.end()) {
theSet.insert(word);
cout << word << endl;
}
}
}
inFile.close();
return 0;
}