Advertisement
Guest User

Untitled

a guest
Feb 21st, 2017
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.19 KB | None | 0 0
  1. #include <iostream>
  2. #include <vector>
  3. #include <string>
  4. #include <algorithm>
  5. #include <queue>
  6. #include <map>
  7.  
  8. using namespace std;
  9.  
  10. int main()
  11. {
  12. #ifdef _DEBUG
  13. freopen("input.txt","r",stdin);
  14. freopen("output.txt","w",stdout);
  15. #endif
  16. //string str = "abcdefghijklmnopqrstuvwxwz";
  17. string str = "абвгдежзийклмнопрстуфхцчшщъыьэюя";
  18. vector <string> a;
  19. map <string, int> m;
  20. while (cin)
  21. {
  22. string s;
  23. getline(cin, s);
  24. if (s != "")
  25. {
  26. a.push_back(s);
  27. }
  28. }
  29.  
  30.  
  31. for (int i = 0; i < str.length(); ++i)
  32. {
  33. for (int j = 0; j < str.length(); ++j)
  34. {
  35. string s = "";
  36. s += str[i], s += str[j];
  37. m.insert(make_pair(s, 0));
  38. }
  39. }
  40.  
  41. for (auto it = m.begin(); it != m.end(); ++it)
  42. {
  43. for (int i = 0; i < a.size(); ++i)
  44. {
  45. for (int j = 0; j < a[i].length(); ++j)
  46. {
  47. int t = j;
  48. int k = 0;
  49. int r = 0;
  50. while(t < a[i].length() && r < it->first.length())
  51. {
  52. if (a[i][t] == it->first[r])
  53. k++;
  54. t++;
  55. r++;
  56. }
  57. if (k == 2)
  58. it->second++;
  59. }
  60. }
  61. }
  62. for (auto it = m.begin(); it != m.end(); ++it)
  63. {
  64. cout << it->first << " " << it->second << endl;
  65. }
  66. return 0;
  67. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement