Advertisement
1nikitas

Untitled

Nov 30th, 2019
596
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.87 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3. #include <set>
  4. #include <map>
  5. using namespace std;
  6.  
  7. using articles = map <string, set <string>>;
  8.  
  9.  
  10. void SplitLine (articles & grammar) {
  11.     if (cin) {
  12.         string vterm, temp;
  13.         cin >> vterm >> temp; // считывание слова и дефиса
  14.         while (cin && ('\n' != cin.peek ())) {
  15.             cin >> temp;
  16.             if (',' == temp [temp.length () - 1]) // последний символ — запятая?
  17.             temp.pop_back ();
  18.             grammar [temp].insert (", " + vterm);
  19.         }
  20.     }
  21. }
  22.  
  23. int main ()
  24. {
  25.     int n;
  26.     cin >> n;
  27.     if (n < 1) return 0;
  28.     articles lat_eng;
  29.     for (int i = 0; i < n; ++i)
  30.         SplitLine (lat_eng);
  31.     cout << lat_eng.size () << endl;
  32.     for (auto now : lat_eng) {
  33.         string desc = "";
  34.         for (auto it : now.second)
  35.             desc += it;
  36.         desc [0] = '-';
  37.         cout << (now.first + ' ' + desc + '\n');
  38.     }
  39.     return 0;
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement