挺水的,简单按照题意模拟就行
-------------------------------------------------
1 #include <iostream>
2 #include <string.h> 3 using namespace std; 4 int w2[3]={ 0,1,2}; 5 int w3[3]={ 3,4,5}; 6 int w4[3]={ 6,7,8}; 7 int w5[3]={ 9,10,11}; 8 int w6[3]={ 12,13,14}; 9 int w7[4]={ 15,16,17,18};10 int w8[3]={ 19,20,21};11 int w9[4]={ 22,23,24,25};12 int wc[26]={ 3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,4,4,4,4,3,3,3,4,4,4,4};13 int wp[26]={ 0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,3,0,1,2,0,1,2,3};14 char w[100];15 int main()16 { 17 cin>>w;18 while(strcmp(w,"#")!=0)19 { 20 int len=strlen(w);21 for(int i=0;i<len;i++)22 { 23 int* tem;24 int c;25 if(w[i]>='A'&&w[i]<='Z')26 c=w[i]-'A';27 if(w[i]>='a'&&w[i]<='z')28 c=w[i]-'a';29 // cout<<w[i]<<c<<endl;30 int n=wc[c];31 // cout<<n<<endl;32 int p=wp[c];33 // cout<<p<<endl;34 if(c<=2)35 tem=w2;36 else if(c<=5)37 tem=w3;38 else if(c<=8)39 tem=w4;40 else if(c<=11)41 tem=w5;42 else if(c<=14)43 tem=w6;44 else if(c<=18)45 tem=w7;46 else if(c<=21)47 tem=w8;48 else if(c<=25)49 tem=w9; 50 for(int j=0;j<=i;j++)51 { 52 p--;53 if(p<0)54 p=n-1;55 }56 char ans;57 if(w[i]>='A'&&w[i]<='Z')58 ans=tem[p]+'A';59 if(w[i]>='a'&&w[i]<='z')60 ans=tem[p]+'a';61 cout<<ans;62 }63 cout<<endl;64 cin>>w;65 }66 }