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 |
Re:我是新手,自己机子上的结果都是好好的,提交就wa了In Reply To:我是新手,自己机子上的结果都是好好的,提交就wa了 Posted by:knuthocean at 2005-03-05 09:59:06 > 分析原因可能是: > 要一块输出,而不能输入一次输出一次 > source code: > > #include <stdio.h> > #include <string.h> > #include <iostream.h> > > void main() > { > char * morse[30]={".-","-...","-.-.","-..",".","..-.","--.", > "....","..",".---","-.-",".-..","--","-.", > "---",".--.","--.-",".-.","...","-","..-", > "...-",".--","-..-","-.--","--..", > "..--",".-.-","---.","----"}; > int input[101]; > char a[501]; > int len[101]; > char c; > int m,n,i=0; int j; > cin>>n; > > > for(int l=0;l<n;l++){ > > for(i=0;i<100;i++){ > scanf("%c",&c); > if(c=='\n') break; > if(('A'<=c)&&(c<='Z')) input[i]=(int)(c-'A'); > else > switch(c){ > case '_': input[i]=26; break; > case ',': input[i]=27; break; > case '.': input[i]=28; break; > case '?': input[i]=29; break; > > } > } > int ilength=i; > printf("%d: ",l+1); > > int index=0;m=0; > for(i=0;i<ilength;i++){ > int k=i; > j=0; > while(j<(int)strlen(morse[input[k]])) > a[index++]=morse[input[k]][j++]; > > > len[m++]=j; > } > > for(i=0;i<m/2;i++){ > int temp =len[i]; > len[i]=len[m-1-i]; > len[m-1-i]=temp; > } > > index=0; > char compare[5]; > > for(i=0;i<m;i++){ > > for(j=0;j<len[i];j++) > compare[j]=a[index++]; > compare[j]='\0'; > > for(j=0;j<30;j++) > if(!strcmp(morse[j],compare)) > break; > > > if((0<=j)&&(j<=25)) > c=(char)j+'A'; > else > switch(j){ > case 26: c='_'; break; > case 27: c=','; break; > case 28: c='.'; break; > case 29: c='?'; break; > } > printf("%c",c); > } > printf("\n"); > } > } > > > > > Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator