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> void main() { int n,t=0,j,k,i; char left[12],right[12],balan[4]; char name[12]={'A','B','C','D','E','F','G','H','I','J','K','L'}; int situ[12]={0,0,0,0,0,0,0,0,0,0,0,0}; //0: unknow; 1: good; 2: heavy; 3:light; scanf("%d",&n); while(t<3*n) { scanf("%s %s %s",&left, &right, &balan); j=0; t++; if(strcmp(balan,"even")==0) while(left[j]!='\0') { for (k=0; k<12; k++) { if(left[j]==name[k]) {situ[k]=1;} if(right[j]==name[k]) {situ[k]=1;} } j++; } else if(strcmp(balan,"up")==0) while(left[j]!='\0') { for (k=0; k<12; k++) { if((left[j]==name[k])&&(situ[k]!=1)) {situ[k]=2;} if((right[j]==name[k])&&(situ[k]!=1)) {situ[k]=3;} } j++; } else while(left[j]!='\0') { for (k=0; k<12; k++) { if((left[j]==name[k])&&(situ[k]!=1)) {situ[k]=3;} if((right[j]==name[k])&&(situ[k]!=1)) {situ[k]=2;} } j++; } if(t%3==0&&t!=0) { for(i=0;i<12;i++) if(situ[i]==2) { printf("%c is the counterfeit coin and it is heavy.\n",name[i]); break; } else if(situ[i]==3) { printf("%c is the counterfeit coin and it is light.\n",name[i]); break; } for(j=0;j<12;j++) situ[j]=0; } } } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator