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> #include <stdio.h> using namespace std; int coin[12],w[12]; void doEven(char *a,char *b) { int i; for(i=0;i<4;i++) coin[b[i]-'A']=coin[a[i]-'A']=1; } void doUp(char *a,char *b) { int i,j,flag; for(i=0;i<12;i++) { flag=1; for(j=0;j<4;j++) if( i == int(a[j]-'A') || i == int(b[j]-'A') ) { flag=0; break; } if(flag) coin[i]=1; } for(i=0;i<sizeof(a)/sizeof(char);i++) { if(w[a[i]-'A']==1) coin[a[i]-'A']=1; else w[a[i]-'A']=0; // heavy if(w[b[i]-'A']==0) coin[b[i]-'A']=1; else w[b[i]-'A']=1; // light; } } int main() { int i,k,n; char a[5],b[5],c[5],*tag; //freopen("in.txt","r",stdin); cin>>n; while(n--) { memset(coin,0,sizeof(coin)); memset(w,-1,sizeof(w)); k=3; while(k--) { cin>>a>>b>>c; switch (c[0]) { case 'e': doEven(a,b); break; case 'u': doUp(a,b); break; case 'd': doUp(b,a); break; } } for(i=0;i<12;i++) { if(coin[i]==0) break; } if(w[i]) tag="light."; else tag="heavy."; cout<<char('A'+i)<<" is the counterfeit coin and it is "<<tag<<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