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 |
谁帮忙看下,谢谢了!!!老是WRO!!!#include<iomanip.h> #include<string.h> int b[12],count,c[12]; char a[3][9]; void hebing(char a1[],char a2[],char a3[]) { int kk=strcmp(a3,"even"),i; if(kk>0) { strcat(a1,a2); strcpy(a[count++],a1); } else if(kk<0) { strcat(a2,a1); strcpy(a[count++],a2); } else { for(i=0;i<4;i++) { b[a1[i]-'A']=1; b[a2[i]-'A']=1; } } } int main() { char a11[9],a22[9],a33[9],b1[9],b2[9],b3[9],c1[9],c2[9],c3[9]; int n,i,j,k; cin>>n; for(k=0;k<n;k++) { for(i=0;i<12;i++) { b[i]=0; c[i]=0; } count=0; cin>>a11>>a22>>a33; hebing(a11,a22,a33); cin>>b1>>b2>>b3; hebing(b1,b2,b3); cin>>c1>>c2>>c3; hebing(c1,c2,c3); for(i=0;i<4;i++) { for(j=0;j<count;j++) { c[a[j][i]-'A']++; } } // cout<<a[0]<<endl; /* for(i=0;i<12;i++) { cout<<b[i]<<' '; } cout<<endl; for(i=0;i<12;i++) { cout<<c[i]<<' '; } cout<<endl;*/ for(i=0;i<12;i++) { if((c[i]==count)&&b[i]==0) { cout<<char('A'+i)<<" is the counterfeit coin and it is "; for(j=0;j<8;j++) { if(a[0][j]==char('A'+i)) { break; } } if(j>=4) { cout<<"light."<<endl; } else { cout<<"heavy."<<endl; } } } ///////////////////////////////////////////////////////// for(i=0;i<12;i++) { c[i]=0; } for(i=4;i<9;i++) { for(j=0;j<count;j++) { c[a[j][i]-'A']++; } } for(i=0;i<12;i++) { if((c[i]==count)&&b[i]==0) { cout<<char('A'+i)<<" is the counterfeit coin and it is "; for(j=0;j<8;j++) { if(a[0][j]==char('A'+i)) { break; } } if(j>=4) { cout<<"light."<<endl; } else { cout<<"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