PersonalCorpus 版 (精华区)
41653 2002-10-14 23:16:33 Accepted
1068 C++ 00:00.00 384K Big Guava
static int len[30]={2,4,4,3,1,4,3,4,2,4,3,4,2,2,3,4,4,3,3,1,3,4,3,
4,4,4,4,4,4,4};
static char * morse[30]={".-","-...","-.-.","-..",".","..-.","--.",
"....","..",".---","-.-",".-..","--","-.","---",".--.","--.-",".-.",
"...","-","..-","...-",".--","-..-","-.--","--..","..--",".-.-","---.",
"----"};
static char p[31]="ABCDEFGHIJKLMNOPQRSTUVWXYZ_,.?";
int main()
{
#ifndef ONLINE_JUDGE
freopen("c:\\0acm\\zju\\i1068","r",stdin);
freopen("c:\\0acm\\zju\\o1068","w",stdout);
#endif
int i,j,k,m,n,l[110];
char s[110],t[500];
scanf("%d\n",&n);
for (m=1;m<=n;m++) {
printf("%d: ",m);
gets(s);
j=0;
for (i=0;s[i]!=0;i++) {
k=strchr(p,s[i])-p;
strcpy(t+j,morse[k]);
l[i]=len[k];
j+=len[k];
}
j=0;
for (i=strlen(s)-1;i>=0;i--)
for (k=0;k<30;k++) if ((len[k]==l[i])&&(strstr(t+j,
morse[k])==t+j)) {
printf("%c",p[k]);
j+=len[k];
break;
}
printf("\n");
}
}
Powered by KBS BBS 2.0 (http://dev.kcn.cn)
页面执行时间:2.318毫秒