#include<string.h>
#include<stdio.h>
_Bool isfake(char c,_Bool light);
char left[3][7];
//={
//{'ABCD'},
//{'ABCI'},
//{'ABIJ'},
//};
char right[3][7];
//={
//{'EFGH'},
//{'EFGK'},
//{'EFGH'},
//};
char result[3][7];
//={
//{'even'},
//{'up'},
//{'even',}
//};
int main(void){
int i=0;
for(i=0;i<3;i++){
scanf("%s %s %s",left[i],right[i],result[i]);
}
char c='A';
for(c='A';c<='L';c++){
if(isfake(c,1)){
printf("%c is the counterfeit coin and it is light",c);
break;
}else if(isfake(c,0)){
printf("%c is the counterfeit coin and it is heavy",c);
break;
}
}
return 0;
}
_Bool isfake(char c,_Bool light){
int ret=0;
int i=0;
char *pleft,*pright,*presult;
for(i=0;i<3;i++){
if(light){
pleft=left[i];
pright=right[i];
presult=result[i];
}
else{
pleft=right[i];
pright=left[i];
presult=result[i];
}
switch(result[i][0]){
case'u':
if(strchr(*pright,c)==NULL){
ret=0;
}
break;
case'd':
if(strchr(*pleft,c)==NULL){
ret=0 ;
}
break;
case'e':
if(strchr(*pleft,c)!=NULL||strchr(*pright,c)!=NULL){
ret=0 ;
}
break;
default:
ret=1;
}
}
return ret;
}
我调试后觉得貌似这个switch只会进入default.
这是原答案