Advertisement
Guest User

Untitled

a guest
Oct 22nd, 2019
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.57 KB | None | 0 0
  1. #include <iostream>
  2. #include <map>
  3. using namespace std;
  4.  
  5. int main(){
  6.  
  7.   string nome;
  8.   int N, poder;
  9.  
  10.   map<int, string> item;
  11.   map<string, int> sort;
  12.   cin>>N;
  13.  
  14.   for(int i=0; i<N; i++){
  15.     cin>>poder;
  16.     cin.ignore();
  17.     getline(cin, nome);
  18.  
  19.     item[poder] = nome;
  20.   }
  21.  
  22.   map<int, string>::iterator it;
  23.   for(it = item.begin(); it != item.end(); it++){
  24.     sort[(*it).second] = (*it).first;    
  25.   }
  26.  
  27.   map<string, int>::iterator it1;
  28.   for(it1 = sort.begin(); it1 != sort.end(); it1++){
  29.     cout<<(*it1).first<< " " << (*it1).second<<endl;
  30.   }
  31.  
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement