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