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 |
Re:cin与scanf有什么区别?In Reply To:cin与scanf有什么区别? Posted by:knuthocean at 2005-03-11 08:10:17 我也是阿,谁想得到!! #include<iostream.h> #include<string.h> #include<stdio.h> char a[3][16],b[3][16],c[3][5]; int checkheavy(int i) { int j=0,k,l,exist; for(l=0;l<3;l++) { exist=0; for(k=0;k<16;k++) { if (a[l][k]=='\0')break; if (a[l][k]==i+65) { exist=1; if (strcmp(c[l],"up")!=0){return 0;} else j=1; } if (b[l][k]==i+65) { exist=1; if (strcmp(c[l],"down")!=0){return 0;} else j=1; } } if(j==1&&exist==0&&strcmp(c[l],"even")!=0)return 0; } return j; } int checklight(int i) { int j=0,k,l,exist; for(l=0;l<3;l++) { exist=0; for(k=0;k<16;k++) { if (a[l][k]=='\0')break; if (a[l][k]==i+65) { exist=1; if (strcmp(c[l],"down")!=0){return 0;} else j=1; } if (b[l][k]==i+65) { exist=1; if (strcmp(c[l],"up")!=0){return 0;} else j=1; } } if(j==1&&exist==0&&strcmp(c[l],"even")!=0)return 0; } return j; } int main() { int i,j,k,l,n; char ch; //cin>>n; scanf("%d",&n); for(i=0;i<n;i++) { //for(j=0;j<3;j++)cin>>a[j]>>b[j]>>c[j]; for(j=0;j<3;j++) { scanf("%s",a[j]); scanf("%s",b[j]); scanf("%s",c[j]); } for(k=0;k<12;k++) { ch=(char)(k+65); if(checkheavy(k)) {cout<<ch<<" is the counterfeit coin and it is heavy."<<endl;break;} else if(checklight(k)) {cout<<ch<<" is the counterfeit coin and it is light."<<endl;break;} } } return 0; } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator