| ||||||||||
| 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 | |||||||||
终于AC了,虽然是一次性过了,可是用了我3小时啊,我的妈啊,有成就感。# include<stdio.h>
# include<string.h>
# include<stdlib.h>
# define N 10
char left[N][7],right[N][7],end[N][5];
int iflight(char ch)
{
int i;
for(i=1;i<=3;i++)
{
if(strcmp(end[i],"even")==0)
if(strchr(left[i],ch)!=NULL||strchr(right[i],ch)!=NULL)
return 0;
if(strcmp(end[i],"up")==0)
if(strchr(right[i],ch)==NULL)
return 0;
if(strcmp(end[i],"down")==0)
if(strchr(left[i],ch)==NULL)
return 0;
continue;
}
return 1;
}
int ifheavy(char ch)
{
int i;
for(i=1;i<=3;i++)
{
if(strcmp(end[i],"even")==0)
if(strchr(left[i],ch)!=NULL||strchr(right[i],ch)!=NULL)
return 0;
if(strcmp(end[i],"up")==0)
if(strchr(left[i],ch)==NULL)
return 0;
if(strcmp(end[i],"down")==0)
if(strchr(right[i],ch)==NULL)
return 0;
continue;
}
return 1;
}
int main()
{
int n,i,j,k1,k2;
char ch;
scanf("%d",&n);
for(i=1;i<=n;i++)
{
for(j=1;j<=3;j++)
scanf("%s %s %s",left[j],right[j],end[j]);
for(ch='A';ch<='L';ch++)
{
k1=k2=0;
k1=iflight(ch);
if(k1==1)
{
printf("%c is the counterfeit coin and it is light.\n",ch);
break;
}
k2=ifheavy(ch);
if(k2==1)
{
printf("%c is the counterfeit coin and it is heavy.\n",ch);
break;
}
}
}
return 0;
}
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator