Problem:
My accepted code is given below:
#include<bits/stdc++.h> using namespace std; int main() { char ar[50],br[50]; string cr; long long i,j; while(cin>>ar>>br) { map<char,char>mp; for(i=0; i<strlen(ar); i++) { mp[ar[i]]=br[i]; mp[ar[i]-32]=br[i]-32; } /*for(int c=0;c<=25;c++) { cout<<mp[ar[c]]<<" "<<mp[ar[c]-32]<<endl; }*/ getchar(); getline(cin,cr); //cout<<"x="<<cr<<endl; //cout<<"x="<<cr<<endl; long long ll=cr.length(); //cout<<"l="<<ll<<endl; for(i=0; i<ll; i++) { //cout<<i<<endl; if((cr[i]>='a'&&cr[i]<='z')||(cr[i]>='A'&&cr[i]<='Z')) cout<<mp[cr[i]]; else cout<<cr[i]; } cout<<endl; } return 0; } //abcdefghijklmnopqrstuvwxyz
No comments:
Post a Comment