1 #include <iostream> 2 #include <stdio.h> 3 #include <string.h> 4 #include <algorithm> 5 6 using namespace std; 7 char s1[30],s2[30]; 8 int mp[256]; 9 char str[1005]; 10 int main(){ 11 scanf("%s%s",s1,s2); 12 int len=strlen(s1); 13 for(int i=0;i<len;i++) 14 mp[s1[i]]=i; //¼Ç¼λÖÃÐÅÏ¢ 15 scanf("%s",str); 16 len=strlen(str); 17 for (int i=0;i<len;i++){ 18 if(str[i]>='A'&&str[i]<='Z') 19 printf("%c",toupper(s2[mp[tolower(str[i])]])); 20 else if(str[i]>='a'&&str[i]<='z') 21 printf("%c",s2[mp[str[i] ] ]); 22 else printf("%c",str[i]); 23 } 24 printf(" "); 25 return 0; 26 }
1 #include <bits/stdc++.h> 2 using namespace std; 3 int main(){ 4 map<char,char>mp; 5 string s1,s2,c; 6 cin>>s1>>s2>>c; 7 for(int i=0;s2[i];i++) 8 mp[s1[i]]=s2[i]; 9 for(int i=0;c[i];i++){ 10 char s; 11 if(c[i]>='0'&&c[i]<='9') 12 s=c[i]; 13 else if(c[i]>='a'&&c[i]<='z') 14 s=mp[c[i]]; 15 else s=mp[c[i]+32]-32; 16 cout<<s; 17 } 18 return 0; 19 }