题目链接:http://bailian.openjudge.cn/practice/2692
# 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;
}