hdu 2816(I Love You Too)(STL)
#include<stdio.h> #include<map> #include<string> #include<iostream> using namespace std; map<string,char>ms; map<char,char>mc; string s1,s2,si; int main() { int t; ms["21"]='A'; ms["22"]='B'; ms["23"]='C'; ms["31"]='D'; ms["32"]='E'; ms["33"]='F'; ms["41"]='G'; ms["42"]='H'; ms["43"]='I'; ms["51"]='J'; ms["52"]='K'; ms["53"]='L'; ms["61"]='M'; ms["62"]='N'; ms["63"]='O'; ms["71"]='P'; ms["72"]='Q'; ms["73"]='R'; ms["74"]='S'; ms["81"]='T'; ms["82"]='U'; ms["83"]='V'; ms["91"]='W'; ms["92"]='X'; ms["93"]='Y'; ms["94"]='Z'; mc['Q']='A'; mc['W']='B'; mc['E']='C'; mc['R']='D'; mc['T']='E'; mc['Y']='F'; mc['U']='G'; mc['I']='H'; mc['O']='I'; mc['P']='J'; mc['A']='K'; mc['S']='L'; mc['D']='M'; mc['F']='N'; mc['G']='O'; mc['H']='P'; mc['J']='Q'; mc['K']='R'; mc['L']='S'; mc['Z']='T'; mc['X']='U'; mc['C']='V'; mc['V']='W'; mc['B']='X'; mc['N']='Y'; mc['M']='Z'; s1.clear(); while(cin>>s1) { s2.clear(); for(int i=0;i<s1.size();i=i+2) { si.clear(); for(int j=i;j<i+2;j++) si+=s1[j]; s2+=ms[si]; } //cout<<s2<<endl; s1.clear(); for(int i=0;i<s2.size();i++) s1+=mc[s2[i]]; string s3,s4;//保存分的两段 t=(s1.size()+1)/2; for(int i=0;i<t;i++) s3+=s1[i]; for(int i=t;i<s1.size();i++) s4+=s1[i]; //cout<<s3<<endl<<s4<<endl; s1.clear(); for(int i=0;i<s3.size();i++) { s1+=s3[i]; if(s4[i]!='\0')s1+=s4[i]; } //cout<<s1<<endl; for(int i=s1.size()-1;i>=0;i--) cout<<s1[i]; cout<<endl; s1.clear(); } return 0; }