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() { int coin[12],i,count,m1,m2,k,c[12]; char a[6][8],b[3][5]; for(i=0;i<12;i++) coin[i]=0; cin>>count; while(count) { for(i=0;i<12;i++) { coin[i]=c[i]=0; } cin>>a[0]>>a[1]; cin>>b[0]; getchar(); cin>>a[2]>>a[3]; cin>>b[1]; getchar(); cin>>a[4]>>a[5]; cin>>b[2]; for(int j=0;j<3;j++) { for(k=0;k<8&&a[j][k];k++) { m1=a[2*j][k]-'A'; m2=a[2*j+1][k]-'A'; if(b[j][0]=='e') { coin[m1]=2; coin[m2]=2; c[m1]=c[m2]=0;} else { if(b[j][0]=='d') { if(coin[m1]!=2) { if(!coin[m1]) {coin[m1]=4; c[m1]++;} else if(coin[m1]==5) {coin[m1]=2; c[m1]=0;} else if(coin[m1]==4) c[m1]++;} if(coin[m2]!=2) { if(!coin[m2]) {coin[m2]=5; c[m2]++;} else if(coin[m2]==4) {coin[m2]=2; c[m2]=0;} else if(coin[m2]==5) c[m2]++;} } else if(b[j][0]=='u') { if(coin[m1]!=2) { if(!coin[m1]) {coin[m1]=5; c[m1]++;} else if(coin[m1]==4) {coin[m1]=2; c[m1]=0;} else if(coin[m1]==5) c[m1]++;} if(coin[m2]!=2) { if(!coin[m2]) {coin[m2]=4; c[m2]++;} else if(coin[m2]==5) {coin[m2]=2; c[m2]=0;} else if(coin[m2]==4) c[m2]++;} } } } } int max=c[0],n=0; for(k=0;k<12;k++) if(c[k]>max) {max=c[k]; n=k;} char ch='A'+n; if(coin[n]==4) cout<<ch<<" is the counterfeit coin and it is light."<<endl; else cout<<ch<<" is the counterfeit coin and it is heavy."<<endl; count--; } return 0; } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator