Advertisement
GastonFontenla

Untitled

May 20th, 2018
194
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.39 KB | None | 0 0
  1. #include <iostream>
  2. #include <map>
  3.  
  4. using namespace std;
  5.  
  6. map <string, int> mapa;
  7.  
  8. int generarId(string s)
  9. {
  10.     if(mapa[s] == 0)
  11.         mapa[s] = mapa.size();
  12.     return mapa[s];
  13. }
  14.  
  15. int main()
  16. {
  17.     int cant;
  18.     cin >> cant;
  19.    
  20.     for(int i=0; i<cant; i++)
  21.     {
  22.         string s;
  23.         cin >> s;
  24.         cout << generarId(s) << endl;
  25.     }
  26.    
  27.     return 0;
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement