WallHero

Map ejemplo

Nov 21st, 2020
643
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. int main()
  5. {
  6.     int N, Q;
  7.     cin >> N >> Q;
  8.     map<string, string> traduccion;
  9.     string aux1, aux2;
  10.     for(int i = 0; i < N; i++)
  11.     {
  12.         cin >> aux1 >> aux2;
  13.         traduccion[aux1] = aux2;
  14.     }
  15.     string query;
  16.     for(int i = 0; i < Q; i++)
  17.     {
  18.         cin >> query;
  19.         if(traduccion[query].empty()) continue;
  20.         cout << traduccion[query] << "\n";
  21.     }
  22.    
  23.    
  24. }
  25.  
RAW Paste Data