Advertisement
TwITe

Untitled

Aug 18th, 2017
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.07 KB | None | 0 0
  1. void lesson8() {
  2. map <string, string> latin_dict;
  3. int n, count = 0;
  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. map <string, set <string> > eng_dict;
  12. vector <char> translate_word;
  13. for (auto pair : latin_dict) {
  14. for (int i = 0; i < pair.second.size(); i++) {
  15. if (isalpha(pair.second[i])) {
  16. translate_word.push_back(pair.second[i]);
  17. }
  18. if (pair.second[i] == ',' || i == pair.second.size() - 1) {
  19. string translate(translate_word.begin(), translate_word.end());
  20. string translation(pair.first.begin(), pair.first.end());
  21. eng_dict[translate].insert(translation);
  22. //translate_word = "";
  23. translate_word.clear();
  24. }
  25. }
  26.  
  27. }
  28. for (auto pair : eng_dict) {
  29. count++;
  30. }
  31. cout << count <<endl;
  32. for (auto pair : eng_dict) {
  33. cout << pair.first << " - ";
  34. for (auto word = pair.second.begin(); word != pair.second.end(); word++) {
  35. cout << *word;
  36. if (word != --pair.second.end()) {
  37. cout << ", ";
  38. }
  39. }
  40. cout << endl;
  41. }
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement