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> main() { char left[20],right[20],result[5],input[3][12],fact[12]; int i,j,t; scanf("%d",&t); //the number of cases for(;t>0;t--) { for(j=0;j<3;j++) { scanf("%s %s %s",left,right,result);//input condition if(strcmp(result,"even")==0) {for(i=1;i<=12;i++) input[j][i]='?'; //can be all the possibilities for(i=0;left[i]!='\0';i++) {input[j][left[i]-64]=0; //real input[j][right[i]-64]=0;} } else {for(i=1;i<=12;i++) input[j][i]=0; if(strcmp(result,"up")==0) for(i=0;left[i]!='\0';i++) {input[j][left[i]-64]=1; //possibly heavy input[j][right[i]-64]=-1;} //possibly light else for(i=0;left[i]!='\0';i++) {input[j][left[i]-64]=-1; //'A'-64=1 input[j][right[i]-64]=1;} } } for(i=1;i<=12;i++) {if(input[0][i]==0||input[1][i]==0||input[2][i]==0) continue; else if(input[0][i]==1||input[1][i]==1||input[2][i]==1) {strcpy(fact,"heavy"); break;} else {strcpy(fact,"light"); break;} } printf("%c is the counterfeit coin and it is %s.\n",i+64,fact); } } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator