-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path源.cpp
More file actions
37 lines (33 loc) · 693 Bytes
/
源.cpp
File metadata and controls
37 lines (33 loc) · 693 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
37
#include"标头.h"
#include "TextQuery.h"
#include"QueryResult.h"
using namespace std;
ostream &print(ostream &os, const QueryResult lh)
{
os << lh.QueryWord << " occur " << lh.lines->size() << " ";
if (lh.lines->size() > 1) { os << "times" << endl; }
else { os << " times" << endl; }
for (auto num : *lh.lines)
{
os << "\t(line " << num << ") "
<< *(lh.Line->begin() + num - 1 )<< endl;
}
return os;
}
void runQueries(ifstream &infile)
{
TextQuery tq(infile);
while (1)
{
cout << "please enter in: " << endl;
string s;
if (!(cin >> s) || s == "q") break;
print( cout, tq.query(s)) << endl;
}
}
int main()
{
ifstream in("test.txt");
runQueries(in);
return 0;
}