| ||||||||||
| 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<iostream.h>
#include<string.h>
int isLight(char);
int isHeavy(char);
int isRight(int i,char v);
int isLeft(int i,char v);
char Left[3][7],Right[3][7],Result[3][7];
void main()
{
int n,i,j;
char v;
cin>>n;
for(i=1;i<=n;i++)
{
for(j=0;j<=2;j++)
{
cin>>Left[j]>>Right[j]>>Result[j];
}
}
for(v='A';v<='L';v++)
{
if(isLight(v))
{
cout<<v<<" is the counterfeit coin and it is light."<<endl;
break;
}
else if(isHeavy(v))
{
cout<<v<<" is the counterfeit coin and it is heavy."<<endl;
break;
}
}
}
int isLight(char v)
{
for(int i=0;i<3;i++)
{
if(Result[i][0]=='u'&&(!isRight(i,v)))
return 0;
if(Result[i][0]=='d'&&(!isLeft(i,v)))
return 0;
if(Result[i][0]=='e'&&((isLeft(i,v)||isRight(i,v))))
return 0;
}
return 1;
}
int isHeavy(char v)
{
for(int i=0;i<3;i++)
{
if(Result[i][0]=='d'&&(!isRight(i,v)))
return 0;
if(Result[i][0]=='u'&&(!isLeft(i,v)))
return 0;
if(Result[i][0]=='e'&&((isLeft(i,v)||isRight(i,v))))
return 0;
}
return 1;
}
int isRight(int i,char v)
{
if(strchr(Right[i],v)==NULL)
return 0;
else return 1;
}
int isLeft(int i,char v)
{
if(strchr(Left[i],v)==NULL)
return 0;
else return 1;
}
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator