Advertisement
STANAANDREY

iTec 2k19 2

Oct 31st, 2019
313
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.19 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. ifstream fin("verbal_tics.in");
  5. ofstream fout("verbal_tics.out");
  6.  
  7. #define NMAX 515
  8. char line[NMAX], sep[] = "./?,;:'@#!- ";
  9. vector <string> vs;
  10. vector <pair <string, string>> :: iterator it;
  11. pair <string, string> ps;
  12. vector < pair <string, string> > ans;
  13.  
  14. int main()
  15. {
  16.     while (fin.getline(line, NMAX))
  17.     {
  18.         char *p = strtok(line, sep);
  19.         while (p)
  20.         {
  21.             vs.push_back(p);
  22.             p = strtok(NULL, sep);
  23.         }
  24.     }
  25.  
  26.     for (int i = 0; i < (int)vs.size() - 2; i++)
  27.     {
  28.         ps.first = vs[i];
  29.         ps.second = vs[i + 1];
  30.         if (ps.first.size() < 3 or ps.second.size() < 3)
  31.             continue;
  32.  
  33.         for (int j = i + 1; j < (int)vs.size() - 1; j++)
  34.             if (ps.first == vs[j] && ps.second == vs[j + 1])
  35.             {
  36.                 it = find(ans.begin(), ans.end(), ps);
  37.                 if (it == ans.end())
  38.                 {
  39.                     ans.push_back(make_pair(ps.first, ps.second));
  40.                 }
  41.             }
  42.     }
  43.  
  44.     for (int i = 0; i < (int)ans.size(); i++)
  45.         fout << ans[i].first << ' ' << ans[i].second << '\n';
  46.  
  47.     return 0;
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement