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 |
是不是有些数据无法确定答案的?高手帮忙看看吧#include <stdio.h> void main() { int n; int flag[20][3]; char num[2][20]; char tmp[10]; int i,j; scanf("%d",&n); while(n--) { for(i=0;i<20;i++) for(j=0;j<3;j++) flag[i][j]=0; for(i=1;i<=3;i++) { scanf("%s %s %s",num[0],num[1],tmp); if(tmp[0]=='e') { for(j=0;num[0][j]!='\0';j++) flag[num[0][j]-'A'][0]=1; for(j=0;num[1][j]!='\0';j++) flag[num[1][j]-'A'][0]=1; } else if(tmp[0]=='u') { for(j=0;num[0][j]!='\0';j++) flag[num[0][j]-'A'][2]=1; for(j=0;num[1][j]!='\0';j++) flag[num[1][j]-'A'][1]=1; } else if(tmp[0]=='d') { for(j=0;num[0][j]!='\0';j++) flag[num[0][j]-'A'][1]=1; for(j=0;num[1][j]!='\0';j++) flag[num[1][j]-'A'][2]=1; } } for(i=0;i<12;i++) if(flag[i][0]!=1&&flag[i][1]+flag[i][2]==1) break; if(flag[i][2]==1) printf("%c is the counterfeit coin and it is heavy.\n",(char)i+'A'); else if(flag[i][1]==1) printf("%c is the counterfeit coin and it is light.\n",(char)i+'A'); } } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator