Advertisement
Spocoman

3. Order

Jan 29th, 2024
1,014
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.52 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3. #include <map>
  4.  
  5. using namespace std;
  6.  
  7. int main()
  8. {
  9.     string line, name, id;
  10.  
  11.     map<string, string> companies;
  12.  
  13.     while (true) {
  14.         getline(cin, line);
  15.         if (line == "end") {
  16.             break;
  17.         }
  18.         name = line.substr(0, line.find(' '));
  19.         id = line.substr(line.find(' ') + 1);
  20.  
  21.         companies.insert({ id, name });
  22.     }
  23.  
  24.     for (auto& c : companies ) {
  25.         cout << c.second << ' ' << c.first << endl;
  26.     }
  27.     return 0;
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement