7 std::vector<std::string> inputs;
10 std::getline(std::cin, temp);
15 if (temp.size() > 1) {
16 inputs.push_back(temp);
21 std::string bigram[2];
25 std::vector<Occurrence> occurrences;
26 for (
unsigned int i = 0; i < inputs.size(); i++) {
27 for (
unsigned int j = 0; j < inputs[i].size() - 1; j++) {
29 for (
unsigned int k = 0; k < occurrences.size(); k++) {
30 if (occurrences[k].bigram[0] == inputs[i].substr(j, 1) &&
31 occurrences[k].bigram[1] == inputs[i].substr(j + 1, 1)
33 occurrences[k].count++;
40 temp.bigram[0] = inputs[i].substr(j, 1);
41 temp.bigram[1] = inputs[i].substr(j + 1, 1);
43 occurrences.push_back(temp);
47 Occurrence mostCommon, currentBigram;
48 for (
unsigned int i = 0; i < occurrences.size(); i++) {
50 mostCommon = occurrences[i];
53 currentBigram = occurrences[i];
54 if (currentBigram.count > mostCommon.count) {
55 mostCommon = currentBigram;
59 std::sort(inputs.begin(), inputs.end());
60 for (
unsigned int i = 0; i < inputs.size(); i++) {
61 if (inputs[i].
find(mostCommon.bigram[0] + mostCommon.bigram[1]) != std::string::npos) {
62 std::cout << inputs[i] << std::endl;