Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- #include <set>
- #include <map>
- using namespace std;
- using articles = map <string, set <string>>;
- void SplitLine (articles & grammar) {
- if (cin) {
- string vterm, temp;
- cin >> vterm >> temp; // считывание слова и дефиса
- while (cin && ('\n' != cin.peek ())) {
- cin >> temp;
- if (',' == temp [temp.length () - 1]) // последний символ — запятая?
- temp.pop_back ();
- grammar [temp].insert (", " + vterm);
- }
- }
- }
- int main ()
- {
- int n;
- cin >> n;
- if (n < 1) return 0;
- articles lat_eng;
- for (int i = 0; i < n; ++i)
- SplitLine (lat_eng);
- cout << lat_eng.size () << endl;
- for (auto now : lat_eng) {
- string desc = "";
- for (auto it : now.second)
- desc += it;
- desc [0] = '-';
- cout << (now.first + ' ' + desc + '\n');
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement