Description
This is a true story. A man showed his love to a girl,but the girl didn't replied clearly ,just gave him a Morse Code:Input
A number string each line(length <= 1000). I ensure all input are legal.Output
An upper alphabet string.Sample Input
4194418141634192622374 41944181416341926223Sample Output
ILOVEYOUTOO VOYEUOOTIO#include<iostream> #include<cstdio> #include<cstring> #include<algorithm> #include<cmath> #include<queue> using namespace std; int main() { char ss[1314],s[1314]; char* a[]={"ABC","DEF","GHI","JKL","MNO","PQRS","TUV","WXYZ"}; char b[]="KXVMCNOPHQRSZYIJADLEGWBUFT"; char d[]="QWERTYUIOPASDFGHJKLZXCVBNM"; //for(int i=0;i<26;i++) // cout<<b[d[i]-'A']<<" "; while(gets(ss)) { int m=strlen(ss); int len=0; for(int i=0;i<m;i++) if(ss[i]!=' ') s[len++]=ss[i]; char s0[520]; int x=0; for(int i=0;i<len;i+=2) { s0[x++]=b[a[s[i]-'2'][s[i+1]-'1']-'A']; } char s1[520]; int y=0; for(int i=0;i<x;i+=2) { s1[i]=s0[y++]; } for(int i=1;i<x;i+=2) { s1[i]=s0[y++]; } for(int i=y-1;i>=0;i--) { putchar(s1[i]); } printf("\n"); } }