elephantsarecool

map2

May 28th, 2018
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.37 KB | None | 0 0
  1. #include<iostream>
  2. #include<map>
  3. #include<string>
  4. using namespace std;
  5. int main()
  6. {
  7.   map<char,char> code;
  8.   int n;
  9.   cin>>n;
  10.   while(n--)
  11.   {
  12.     char c1,c2;
  13.     cin>>c1>>c2;
  14.     code[c1]=c2;
  15.   }
  16.   string text;
  17.   cin.ignore();
  18.   getline(cin,text);
  19.   for(int i=0;i<text.length();++i)
  20.     if(code[text[i]])
  21.       text[i]=code[text[i]];
  22.   cout<<text<<endl;
  23. }
Add Comment
Please, Sign In to add comment