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 |
为什么会是runtime error?郁闷死了:(编了一个上午,在机器上运行答案对了,可是交上来就是runtime error,气死我了。各位帮帮忙阿。。。 #include <stdio.h> #include <string.h> void main() { int n,i,j,k,l; int bal[2],unbal; int m=0,len; char left[3][5],right[3][5],result[3][5]; char s[20]; scanf("%d",&n); for(i=0;i<n;i++) { for(j=0;j<3;j++) scanf("%s %s %s",left[j],right[j],result[j]); for(j=0;j<3;j++) { if(result[j][0]=='e') {bal[m]=j;m++;} else unbal=j; if(j==2) break; } strcpy(s,left[bal[0]]); strcat(s,right[bal[0]]); len=strlen(s); for(k=0;k<5;k++) { if(left[bal[0]][k]!=left[bal[1]][k]) {s[len]=left[bal[1]][k]; len++;} } for(k=0;k<5;k++) { if(right[bal[0]][k]!=right[bal[1]][k]) {s[len]=right[bal[1]][k]; len++;} } len=strlen(s); for(k=0;k<4;k++) { for(l=0;l<len;l++) { if(left[unbal][k]==s[l]) break; else if(l==len-1&&result[unbal][0]=='u') { printf("%c is the counterfeit coin and it is heavy.\n",left[unbal][k]); break; } else if(l==len-1&&result[unbal][0]=='d') { printf("%c is the counterfeit coin and it is light.\n",left[unbal][k]); break; } } } for(k=0;k<4;k++) { for(l=0;l<len;l++) { if(right[unbal][k]==s[l]) break; else if(l==len-1&&result[unbal][0]=='u') { printf("%c is the counterfeit coin and it is light.\n",right[unbal][k]); break; } else if(l==len-1&&result[unbal][0]=='d') { printf("%c is the counterfeit coin and it is heavy.\n",right[unbal][k]); break; } } } } } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator