这个题最麻烦的是数组的初始化,不过还好一次ac。
#include<iostream>
using namespace std;
int main()
{
char a[10][5],b[1000],c[200],e[1000],f[1000];
int num,sum,n,m,i,j=0,s,j1;
a[2][1]='A';a[2][2]='B';a[2][3]='C';a[3][1]='D';a[3][2]='E';a[3][3]='F';
a[4][1]='G';a[4][2]='H';a[4][3]='I';a[5][1]='J';a[5][2]='K';a[5][3]='L';
a[6][1]='M';a[6][2]='N';a[6][3]='O';a[7][1]='P';a[7][2]='Q';a[7][3]='R';
a[7][4]='S';a[8][1]='T';a[8][2]='U';a[8][3]='V';a[9][1]='W';a[9][2]='X';
a[9][3]='Y';a[9][4]='Z';
c['Q']='A';c['W']='B';c['E']='C';c['R']='D';c['T']='E';c['Y']='F';
c['U']='G';c['I']='H';c['O']='I';c['P']='J';c['A']='K';c['S']='L';
c['D']='M';c['F']='N';c['G']='O';c['H']='P';c['J']='Q';c['K']='R';
c['L']='S';c['Z']='T';c['X']='U';c['C']='V';c['V']='W';c['B']='X';
c['N']='Y';c['M']='Z';
while(cin>>b)
{
j=0;
j1=0;
s=strlen(b);
for(i=0;i<s-1;i=i+2)
{
j++;
m=b[i]-'0';
n=b[i+1]-'0';
e[j]=c[a[m][n]];
}
if(j%2==0)
num=j/2;
else
num=j/2+1;
m=num+1;
for(n=1;n<=num;n++)
{
f[j1]=e[n];
j1++;
if(m<=j)
{ f[j1]=e[m];
j1++;
m++;}
}
for(i=j-1;i>=0;i--)
printf("%c",f[i]);
cout<<endl;
}
return 0;
}