| ||||||||||
| 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>
#include<stdio.h>
char left[3][7],right[3][7],result[3][7];
int isleft(int i,char x){
int k,p;
p=strlen(left[i]);
for(k=0;k<p;k++)
if(left[i][k]==x)
return 1;
return 0;
}
int isright(int i,char x){
int k,p;
p=strlen(right[i]);
for(k=0;k<p;k++)
if(right[i][k]==x)
return 1;
return 0;
}
int light(char x){
int j;
for(j=0;j<3;j++)
switch(result[j][0]){
case 'u':if(!isright(j,x))
return 0;break;
case 'e':if(isright(j,x)||isleft(j,x))
return 0;break;
case 'd':if(!isleft(j,x))
return 0;break;
}
return 1;
}
int heavy(char x){
int j;
for(j=0;j<3;j++)
switch(result[j][0]){
case 'u':if(!isright(j,x))
return 0;break;
case 'e':if(isright(j,x)||isleft(j,x))
return 0;break;
case 'd':if(!isleft(j,x))
return 0;break;
}
return 1;
}
void main()
{
char c;
int i,j,k;
cin>>j;
for(k=0;k<j;k++){
for(i=0;i<3;i++)
cin>>left[i]>>right[i]>>result[i];
for(c='A';c<='L';c++){
if(light(c)){
cout<<c<<" is the counterfeit coin and it is light.\n";
}
else
if(heavy(c)){
cout<<c<<" is the counterfeit coin and it is heavy.\n";
}
}
}
}
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator