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 |
why WA? help.#include"stdio.h" #include"string.h" int ab(int x) { return x>=0?x:-x; } int main() { char r1[12],r2[12],s[6]; int n,i,j,ca,g[12],k; bool f[12]; scanf("%d",&ca); while(ca--) { memset(g,0,sizeof(g)); memset(f,false,sizeof(f)); for(i=0;i<3;i++) { scanf("%s %s %s",r1,r2,s); if(strcmp(s,"even")==0) for(j=0;j<strlen(r1)&&j<strlen(r2);j++) { f[r1[j]-'A']=true; f[r2[j]-'A']=true; } else if(strcmp(s,"up")==0) { for(j=0;j<strlen(r1)&&j<strlen(r2);j++) { g[r1[j]-'A']++; g[r2[j]-'A']--; } } else { for(j=0;j<strlen(r1)&&j<strlen(r2);j++) { g[r1[j]-'A']--; g[r2[j]-'A']++; } } } for(i=0;i<11;i++) if(f[i])g[i]=0; n=0; for(i=0;i<11;i++) if(n<ab(g[i])) { n=ab(g[i]);j=i; if(g[i]>0) k=1; else k=0; } printf("%c is the counterfeit coin and it is ",'A'+j); if(!k) printf("light.\n"); else printf("heavy.\n"); } return 0; } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator