| ||||||||||
| 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 | |||||||||
枚举法,帮偶排一下错吧,可能很弱智,但自己发现不了,compile不了#include <iostream>
#include <string.h>
using namespace std;
char c;
char left[3][7],right[3][7],status[3][10];
int inLeft(int i,char x)
{
for(int j=0;j<strlen(left[i]);j++)
{
if(left[i][j] == x)
return 1;
}
return 0;
}
int inRight(int i,char x)
{
for(int j=0;j<strlen(right[i]);j++)
{
if(right[i][j] == x)
return 1;
}
return 0;
}
int isLight(char c)
{
for(int i=0;i<3;i++)
{
switch(status[i][0])
{
case 'u':
if(!inRight(i,c)) return 0;
break;
case 'd':
if(!inLeft(i,c)) return 0;
break;
case 'e':
if(inRight(i,c) || inLeft(i,c)) return 0;
break;
}
}
return 1;
}
int isHeavy(char c)
{
for(int i=0;i<3;i++)
{
switch(status[i][0])
{
case 'u':
if(!inLeft(i,c)) return 0;
break;
case 'd':
if(!inRight(i,c)) return 0;
break;
case 'e':
if(inRight(i,c) || inLeft(i,c)) return 0;
break;
}
}
return 1;
}
int main()
{
int n;
cin>>n;
while(n--)
{
for(int i=0;i<3;i++)
{
cin>>left[i]>>right[i]>>status[i];
}
for(;c>='A'&&c<='L';c++)
{
if(isLight(c))
{
cout<<c<<" is the counterfeit coin and it is light."<<endl;
break;
}
if(isHeavy(c))
{
cout<<c<<" is the counterfeit coin and it is heavy."<<endl;
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