-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cpp
55 lines (43 loc) · 1.03 KB
/
main.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
#include "TBohr.h"
int main() {
std::vector<std::pair<int, int> > grid;
std::vector<TLetter> input;
std::vector<TLetter> patterns;
std::string line, word;
TLetter pattern;
TBohr b;
int index = 0;
while (std::getline(std::cin, pattern) && !pattern.empty()) {
std::stringstream AlineStream(pattern);
while (AlineStream >> word) {
for(unsigned int i = 0; i < word.length(); ++i) {
word[i] = tolower(word[i]);
}
patterns.push_back(word);
index++;
}
b.Push(patterns);
b.pieceIndex.push_back(index);
index = 0;
pattern.clear();
patterns.clear();
}
int lineIndex = 1, wordIndex = 1;
while (std::getline(std::cin, line)) {
std::stringstream lineStream(line);
while (lineStream >> word) {
for(unsigned int i = 0; i < word.length(); ++i) {
word[i] = tolower(word[i]);
}
input.push_back(word);
grid.push_back(std::make_pair(lineIndex, wordIndex));
wordIndex++;
}
wordIndex = 1;
lineIndex++;
}
input.shrink_to_fit();
grid.shrink_to_fit();
b.Search(input, grid);
return 0;
}