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 |
老大,能给我1013题错误的数据点吗?In Reply To:要求稳定排序,你原来的程序能保证吗 Posted by:hawk at 2005-04-28 12:04:07 #include<stdio.h> #include<string.h> main() { char left[20],right[20],result[5],input[3][12],fact[12]; int i,j,t; scanf("%d",&t); //the number of cases for(;t>0;t--) { for(i=0;i<3;i++) for(j=0;j<12;j++) input[i][j]='?'; for(j=0;j<3;j++) { scanf("%s %s %s",left,right,result);//input condition if(strcmp(result,"even")==0) {for(i=0;i<12;i++) input[j][i]='?'; //can be all the possibilities for(i=0;left[i]!='\0';i++) {input[j][left[i]-65]=(input[j][left[i]-65]==0)? '?':0; //real input[j][right[i]-65]=(input[j][right[i]-65]==0)? '?':0;} } else {for(i=0;i<12;i++) input[j][i]=0; if(strcmp(result,"up")==0) for(i=0;left[i]!='\0';i++) {input[j][left[i]-65]=(input[j][left[i]-65]==-1)? 0:1; //possibly heavy input[j][right[i]-65]=(input[j][right[i]-65]==1)? 0:-1;} //possibly light else for(i=0;left[i]!='\0';i++) {input[j][left[i]-65]=(input[j][left[i]-65]==1)? 0:-1; //'A'-65=0 input[j][right[i]-65]=(input[j][right[i]-65]==-1)? 0:1;} } } for(i=0;i<12;i++) {if(input[0][i]==0||input[1][i]==0||input[2][i]==0) continue; else if(input[0][i]==1||input[1][i]==1||input[2][i]==1) {strcpy(fact,"heavy"); break;} else {strcpy(fact,"light"); break;} } printf("%c is the counterfeit coin and it is %s.\n",i+65,fact); } } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator