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:很疑惑的一点,ai.pku.edu.cn/JudgeOnline上的2692题应该是这道题的中文翻译及化简吧,但为什么这道题过了那道题却过不了呢???In Reply To:很疑惑的一点,ai.pku.edu.cn/JudgeOnline上的2692题应该是这道题的中文翻译及化简吧,但为什么这道题过了那道题却过不了呢??? Posted by:00548064 at 2007-01-26 09:21:50 #include<stdio.h> #include<string.h> char left[3][7]; char right[3][7]; char result[3][7]; bool islight(char); bool isheavy(char); bool islight(char x) { int j; for(j=0;j<3;j++) switch(result[j][0]){ case 'u':if(strchr(right[j],x)==NULL)return false; break; case 'e':if(strchr(left[j],x)!=NULL || strchr(right[j],x)!=NULL)return false; break; case 'd':if(strchr(left[j],x) == NULL)return false; break; } return true; } bool isheavy(char x) { int j; for(j=0;j<3;j++) switch(result[j][0]){ case 'u':if(strchr(left[j],x)==NULL)return false; break; case 'e':if(strchr(left[j],x)!=NULL || right[j]!=NULL)return false; break; case 'd':if(strchr(right[j],x)==NULL)return false; break; } return true; } int main() { int n,i; scanf("%d",&n); while(n--) { for(i=0;i<3;i++) scanf("%s %s %s",left[i],right[i],result[i]); for(i='A';i<='L';i++) { if(islight(i)){ printf("%c is the counterfeit coin and it is light.\n",i); break; } if(isheavy(i)){ printf("%c is the counterfeit coin and it is heavy.\n",i); break; } } } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator