百练 1013 Counterfeit Dollar

来源:互联网 发布:点雇网 在线全职美工 编辑:程序博客网 时间:2024/05/01 17:18

题目链接:http://bailian.openjudge.cn/practice/1013

# include <stdio.h># include <string.h> char left[3][7],right[3][7],result[3][5];int isLight(char c){int i;for(i=0;i<3;i++){switch(result[i][0]){case 'e':if(strchr(right[i],c) != NULL || strchr(left[i],c)!=NULL)return 0;break;case 'u':if(strchr(right[i],c)==NULL)return 0;break;case 'd':if(strchr(left[i],c)==NULL)return 0;break;}}return 1;}int isHeavy(char c){int i;for(i=0;i<3;i++){switch(result[i][0]){case 'e':if(strchr(right[i],c)!=NULL||strchr(left[i],c)!=NULL)return 0;break;case 'u':if(strchr(left[i],c)==NULL)return 0;break;case 'd':if(strchr(right[i],c)==NULL)return 0;break;}}return 1;}int main(){int n,i;char c;scanf("%d",&n);while(n>0){for(i=0;i<3;i++){scanf("%s %s %s", left[i],right[i],result[i]);}for(c='A';c<='L';c++){if(isLight(c)){printf("%c is the counterfeit coin and it is light.\n",c);break;}if(isHeavy(c)){printf("%c is the counterfeit coin and it is heavy.\n",c);break;}}n--;}return 0;}


原创粉丝点击