| ||||||||||
| 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 | |||||||||
干净 大方#include<stdio.h>
#include<string.h>
char right[3][7],lift[3][7],hehe[3][5];
int qing(char);
int zhong(char);
void main(void)
{
int n,i;
char ch;
scanf("%d",&n);
while(n--)
{
memset(right,'\0',sizeof(right));
memset(lift,'\0',sizeof(lift));
memset(hehe,'\0',sizeof(hehe));
for(i=0;i<=2;i++)
scanf("%s %s %s",right[i],lift[i],hehe[i]);
for(ch='A';ch<='L';ch++)
{
if(qing(ch))
{
printf("%c is the counterfeit coin and it is light.\n", ch);
break;
}
if(zhong(ch))
{
printf("%c is the counterfeit coin and it is heavy.\n", ch);
break;
}
}
}
}
int qing(char a)
{
int i;
for(i=0;i<=2;i++)
switch(hehe[i][0])
{
case 'u':if(strchr(lift[i],a)==NULL)return 0;
break;
case 'e':if(strchr(lift[i],a)!=NULL||strchr(right[i],a)!=NULL)return 0;
break;
case 'd':if(strchr(right[i],a)==NULL)return 0;
break;
}
return 1;
}
int zhong(char a)
{
int i;
for(i=0;i<=2;i++)
switch(hehe[i][0])
{
case 'u':if(strchr(right[i],a)==NULL)return 0;
break;
case 'e':if(strchr(lift[i],a)!=NULL||strchr(right[i],a)!=NULL)return 0;
break;
case 'd':if(strchr(lift[i],a)==NULL)return 0;
break;
}
return 1;
}
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator