Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
为什么WA?我的程序: #include<stdio.h> #include<string.h> int main() { const char m[][31]={ "", ".-", "-...","-.-.","-..", ".", "..-.","--.", "....","..", ".---","-.-", ".-..","--", "-.", "---", ".--.","--.-",".-.", "...", "-", "..-", "...-",".--", "-..-","-.--","--..","..--","---.",".-.-", "----"}; char u[100][100]; char tmp[400],tmp2[100],tmp3[4]; int i,j,k,n,t,len,l[100],lu,a,b; scanf("%d",&n); n--; for(i=0;i<=n;i++) scanf("%s",&u[i]); for(i=0;i<=n;i++){ strset(tmp,'\0'); strset(tmp2,'\0'); lu=strlen(u[i]); len=0; for(j=0;j<=lu-1;j++){ if((u[i][j]-64<=26)&&u[i][j]>64)t=u[i][j]-64; else switch(u[i][j]){ case'_':t=27;break; case'.':t=28;break; case',':t=29;break; case'?':t=30;break; } l[j]=strlen(m[t]); len+=l[j]; strcat(tmp,m[t]); } b=-1; for(j=lu-1;j>=0;j--){ a=b+1; b=a+l[j]-1; tmp3[0]=tmp3[1]=tmp3[2]=tmp3[3]='\0'; for(k=a;k<=b;k++) tmp3[k-a]=tmp[k]; for(k=1;k<=30;k++) if(strcmp(tmp3,m[k])==0){ if(k<=26)t=k+64; else switch(k){ case 27:t='_';break; case 28:t='.';break; case 29:t=',';break; case 30:t='?';break; } tmp2[lu-j-1]=t; break; } } strcpy(u[i],tmp2); u[i][lu]='\0'; } for(i=0;i<=n;i++) printf("%s\n",u[i]); } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator