-
Notifications
You must be signed in to change notification settings - Fork 0
/
CounterSearchLine.cpp
61 lines (42 loc) · 1.23 KB
/
CounterSearchLine.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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#include <iostream>
#include <string>
#include <sstream>
#include <fstream>
#include <set>
#include <vector>
#include <cstdlib>
#include <boost/algorithm/string/split.hpp>
#include <boost/algorithm/string.hpp>
#include <boost/lexical_cast.hpp>
using namespace std;
using namespace boost;
int main (int argc, char **argv) {
cerr << "SearchLine <STRING, key_file> <INT, key_position> <STRING, search_file> <INT, search_position>" << endl;
ifstream kinf(argv[1]);
int key_pos = atoi(argv[2]) - 1;
ifstream inf(argv[3]);
int search_pos = atoi(argv[4]) - 1;
set<string> key_set;
set<string>::iterator it;
while(kinf){
string strInput;
getline(kinf, strInput);
if(strInput.length() > 0){
vector<string> vec;
split(vec, strInput, is_any_of("\t"));
key_set.insert(vec[key_pos]);
}
}
while(inf){
string strInput;
getline(inf, strInput);
if(strInput.length() > 0){
vector<string> vec;
split(vec, strInput, is_any_of("\t"));
it = key_set.find(vec[search_pos]);
if(it == key_set.end()) cout << strInput << endl;
}
}
kinf.close(); inf.close();
return 0;
}