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 |
cin与scanf有什么区别?郁闷,原来要反cin改成scanf!!!这谁想得到呀? #include <iostream.h> #include <stdio.h> #include <string.h> char input1[3][16],input2[3][16],input3[3][5]; int count(char a[],char c) { int i; int result=0; for(i=0;a[i]!='\0';i++) if(a[i]==c) result+=1; return result; } int judge(char c) { int compare[3],left[3]; int i; for(i=0;i<3;i++){ compare[i]=strcmp(input3[i],"even"); left[i]=count(input1[i],c)-count(input2[i],c); } int times=0,t; for(i=0;i<3;i++){ if(compare[i]==0){ if(left[i]!=0) {return 0;} } else{ if(left[i]==0) {return 0;} if(times){ int t1=compare[i]*left[i]; if(t1*t<0) {return 0;} } if(!times){ t=compare[i]*left[i]; times=1; } } } int flag=0; for(i=0;i<3;i++){ if(compare[i]!=0){ if(compare[i]*left[i]>0) flag=1; } } if(flag) cout<<c<<" is the counterfeit coin and it is heavy."<<endl; else cout<<c<<" is the counterfeit coin and it is light."<<endl; return 1; } void main() { int i,n; char list[12]={'A','B','C','D','E','F','G','H','I','J','K','L'}; scanf("%d",&n); //cin>>n; for(int l=0;l<n;l++){ for(i=0;i<3;i++){ scanf("%s",input1[i]); scanf("%s",input2[i]); scanf("%s",input3[i]); } for(i=0;i<12;i++) if(judge(list[i])) break; } } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator