| ||||||||||
| 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 | |||||||||
我崩溃了(附带代码),高手帮忙找找WA的原因,我已经穷途末路了......#include <iostream>
using namespace std;
int main()
{
char z[3][7],y[3][7],r[3][6];
int Num;
cin >>Num;
for(int k=0;k<Num;k++){
for(int i=0;i<3;i++){
scanf("%s%s%s",z[i],y[i],r[i]);
}
for(char coin='A';coin<='L';coin++){
int a[3]={1,1,1},b[3]={1,1,1};
for(int i=0;i<3;i++){
int R=0,L=0;
for(int j=0;j<7;j++){
if(coin==z[i][j]){
L=1;break;
}
if(coin==y[i][j]){
R=1;break;
}
}
switch(r[i][0]){
case'u':if(R!=1)a[i]=0;
break;
case'e':if(R==1||L==1)a[i]=0;
break;
case'd':if(L!=1)a[i]=0;
break;
}
switch(r[i][0]){
case'u':if(L!=1)b[i]=0;
break;
case'e':if(R==1||L==1)b[i]=0;
break;
case'd':if(R!=1)b[i]=0;
break;
}
}
if((a[0]+a[1]+a[2])==3)
cout <<coin<<" is the counterfeit coin and it is light."<<endl;
if((b[0]+b[1]+b[2])==3)
cout <<coin<<" is the counterfeit coin and it is heavy."<<endl;
}
}
return 0;
}
Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator