因为本人很懒,不想去找什么,ASCII码的规律......
就又开了一个cpp,打了一份if&else 的表。
1 #include <bits/stdc++.h> 2 using namespace std; 3 char a[50]; 4 char b[50]; 5 6 /*A B C D E F G H I J K L M N O P Q R S T U V W X Y Z 7 V W X Y Z A B C D E F G H I J K L M N O P Q R S T U*/ 8 9 int main() 10 { 11 for(int i=1;i<=26;i++) cin>>a[i]; 12 for(int i=1;i<=26;i++) cin>>b[i]; 13 for(int i=1;i<=26;i++) cout<<a[i]; 14 for(int i=1;i<=26;i++) cout<<b[i]; 15 for(int i=0;i<=26;i++) 16 printf("else if(ch[i] == ‘%c‘) ans[i]=‘%c‘;\n",a[i],b[i]); 17 return 0; 18 }
Ctrl+C && Tab一下就完成了!!!
1 #include<bits/stdc++.h> 2 using namespace std; 3 const int maxn=1e6 + 5; 4 char ch[maxn],ans[maxn]; 5 int main() 6 { 7 while(scanf("%s",ch)!=EOF) 8 { 9 int len=strlen(ch); 10 for(int i=0;i<len;i++) 11 { 12 if(‘A‘<=ch[i] && ch[i]<=‘Z‘) 13 { 14 if(ch[i] == ‘A‘) ans[i]=‘V‘; 15 else if(ch[i] == ‘B‘) ans[i]=‘W‘; 16 else if(ch[i] == ‘C‘) ans[i]=‘X‘; 17 else if(ch[i] == ‘D‘) ans[i]=‘Y‘; 18 else if(ch[i] == ‘E‘) ans[i]=‘Z‘; 19 else if(ch[i] == ‘F‘) ans[i]=‘A‘; 20 else if(ch[i] == ‘G‘) ans[i]=‘B‘; 21 else if(ch[i] == ‘H‘) ans[i]=‘C‘; 22 else if(ch[i] == ‘I‘) ans[i]=‘D‘; 23 else if(ch[i] == ‘J‘) ans[i]=‘E‘; 24 else if(ch[i] == ‘K‘) ans[i]=‘F‘; 25 else if(ch[i] == ‘L‘) ans[i]=‘G‘; 26 else if(ch[i] == ‘M‘) ans[i]=‘H‘; 27 else if(ch[i] == ‘N‘) ans[i]=‘I‘; 28 else if(ch[i] == ‘O‘) ans[i]=‘J‘; 29 else if(ch[i] == ‘P‘) ans[i]=‘K‘; 30 else if(ch[i] == ‘Q‘) ans[i]=‘L‘; 31 else if(ch[i] == ‘R‘) ans[i]=‘M‘; 32 else if(ch[i] == ‘S‘) ans[i]=‘N‘; 33 else if(ch[i] == ‘T‘) ans[i]=‘O‘; 34 else if(ch[i] == ‘U‘) ans[i]=‘P‘; 35 else if(ch[i] == ‘V‘) ans[i]=‘Q‘; 36 else if(ch[i] == ‘W‘) ans[i]=‘R‘; 37 else if(ch[i] == ‘X‘) ans[i]=‘S‘; 38 else if(ch[i] == ‘Y‘) ans[i]=‘T‘; 39 else if(ch[i] == ‘Z‘) ans[i]=‘U‘; 40 } 41 else ans[i]=ch[i]; 42 } 43 for(int i=0;i<len;i++) printf("%c",ans[i]); 44 printf(" "); 45 } 46 return 0; 47 }
原文地址:https://www.cnblogs.com/pengcheng-official/p/9459607.html
时间: 2024-10-04 09:11:34