Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 1725 Accepted Submission(s): 1037
4194418141634192622374 41944181416341926223
ILOVEYOUTOO VOYEUOOTIO
#include<stdio.h> #include<string.h> #include<stdlib.h> #include<math.h> #include<queue> #include<stack> #include<algorithm> using namespace std; char s1[]={"QWERTYUIOPASDFGHJKLZXCVBNM"}; char s2[]={"ABCDEFGHIJKLMNOPQRSTUVWXYZ"}; char s[1010]; char a[1010],b[1010]; int top; char map[10][5]; void solve(char c) { int i,j; for(i=0;s1[i];i++) { if(s1[i]==c) { s[top++]=s2[i]; break; } } } int main() { int i,j,l; int len; char str[1010]; char c; strcpy(map[2],".ABC."); strcpy(map[3],".DEF."); strcpy(map[4],".GHI."); strcpy(map[5],".JKL."); strcpy(map[6],".MNO."); strcpy(map[7],".PQRS"); strcpy(map[8],".TUV."); strcpy(map[9],".WXYZ"); while(gets(str)) { l=strlen(str); memset(s,'\0',sizeof(s)); top=0; for(i=0;i<l;i++) { c=map[str[i]-'0'][str[i+1]-'0']; solve(c); ++i; } len=strlen(s); if(len&1) len+=1; //printf("%s\n",s); memset(a,'\0',sizeof(a)); memset(b,'\0',sizeof(b)); for(i=0;i<len/2;i++) { a[i]=s[i]; } j=0; for(;i<strlen(s);i++) { b[j++]=s[i]; } memset(s,'\0',sizeof(s)); top=0; for(i=0;i<strlen(a);i++) { if(a[i]) s[top++]=a[i]; if(b[i]) s[top++]=b[i]; } strrev(s); printf("%s\n",s); //printf("%s\n%s\n",a,b); //printf("%s\n",s);*/ } return 0; }
#include<cstdio> #include<cstdlib> #include<cstring> using namespace std; char str[1010]; char phone[15][10]={"1","1","1ABC","1DEF","1GHI","1JKL","1MNO","1PQRS","1TUV","1WXYZ"}; char s[1010]; char ss[1010]; int main() { int l,i,k,j; while(scanf("%s",str)!=EOF) { l=strlen(str);k=0; for(i=0;i<l;i+=2) { s[k++]=phone[str[i]-'0'][str[i+1]-'0']; } for(i=0;i<k;++i) { if(s[i]=='Q')s[i]='A'; else if(s[i]=='W')s[i]='B'; else if(s[i]=='E')s[i]='C'; else if(s[i]=='R')s[i]='D'; else if(s[i]=='T')s[i]='E'; else if(s[i]=='Y')s[i]='F'; else if(s[i]=='U')s[i]='G'; else if(s[i]=='I')s[i]='H'; else if(s[i]=='O')s[i]='I'; else if(s[i]=='P')s[i]='J'; else if(s[i]=='A')s[i]='K'; else if(s[i]=='S')s[i]='L'; else if(s[i]=='D')s[i]='M'; else if(s[i]=='F')s[i]='N'; else if(s[i]=='G')s[i]='O'; else if(s[i]=='H')s[i]='P'; else if(s[i]=='J')s[i]='Q'; else if(s[i]=='K')s[i]='R'; else if(s[i]=='L')s[i]='S'; else if(s[i]=='Z')s[i]='T'; else if(s[i]=='X')s[i]='U'; else if(s[i]=='C')s[i]='V'; else if(s[i]=='V')s[i]='W'; else if(s[i]=='B')s[i]='X'; else if(s[i]=='N')s[i]='Y'; else if(s[i]=='M')s[i]='Z'; } k++; j=k/2;i=0; int n=0; while(i<k/2||j<k-1) { if(i<k/2)ss[n++]=s[i++]; if(j<k-1)ss[n++]=s[j++]; } for(i=n-1;i>=0;--i) printf("%c",ss[i]); printf("\n"); } return 0; }