Advertisement
Guest User

Untitled

a guest
Dec 20th, 2014
136
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.78 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3. #include <map>
  4.  
  5. using namespace std;
  6.  
  7. typedef map<string,string>::iterator ite;
  8.  
  9. int main() {
  10. string s;
  11. map<string,string> liats;
  12. while(cin >> s) {
  13. if (s == "affair") {
  14. string x, y;
  15. cin >> x >> y;
  16. if (liats[x] != "") liats[liats[x]] = "";
  17. if (liats[y] != "") liats[liats[y]] = "";
  18. liats[x] = y;
  19. liats[y] = x;
  20. }
  21. else {
  22. cout << "COUPLES:" << endl;
  23. for (ite it = liats.begin(); it != liats.end(); ++it)
  24. if (it->second != "" and it->first < it->second)
  25. cout << it->first << " " << it->second << endl;
  26. cout << "ALONE:" << endl;
  27. for (ite it = liats.begin(); it != liats.end(); ++it)
  28. if (it->second == "")
  29. cout << it->first << endl;
  30. cout << "----------" << endl;
  31. }
  32. }
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement