Advertisement
TwITe

Untitled

Aug 15th, 2017
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.89 KB | None | 0 0
  1. void lesson8() {
  2.     map <string, string> latin_dict;
  3.     int n;
  4.     cin >> n;
  5.     for (int i = 0; i < n; i++) {
  6.         string key, value;
  7.         cin >> key;
  8.         getline(cin, value);
  9.         latin_dict[key] = value;
  10.     }
  11.     cout << endl;
  12.     for (auto i : latin_dict) {
  13.         cout << i.first << i.second << endl;
  14.     }
  15.     cout << endl;
  16.     cout << endl;
  17.     map <string, vector <string> > eng_dict;
  18.     vector <char> translate_word;
  19.     for (auto i : latin_dict) {
  20.         for (int k = 0; k < i.second.size(); k++) {
  21.             if (isalpha(i.second[k])) {
  22.                 translate_word.push_back(i.second[k]);
  23.             }
  24.             if (i.second[k] == ',' || k == i.second.size() - 1) {
  25.                 string translate(translate_word.begin(), translate_word.end());
  26.                 eng_dict[translate].push_back(i.first);
  27.                 //translate_word = "";
  28.                 translate_word.clear();
  29.             }
  30.         }
  31.     }
  32.     cout << endl;
  33.     cout << endl;
  34.     for (auto i : eng_dict) {
  35.         cout << i.first << " - " << i.second << endl;
  36.     }
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement