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 |
大牛们,帮忙看看, VC可已执行,却不能AC#include<iostream> #include<string> using std::string; using std::cin; using std::cout; using std::endl; char left[3][7],right[3][7],result[3][5]; bool h(char x) { for(int i=0;i<3;i++) { switch(result[i][0]) { case 'e':if(strchr(left[i],x)!=NULL||strchr(right[i],x)!=NULL)return false;break; case 'u':if(strchr(left[i],x)==NULL)return false;break; case 'd':if(strchr(right[i],x)==NULL)return false;break; } } return true; } bool l(char x) { for(int i=0;i<3;i++) { switch(result[i][0]) { case 'e':if(strchr(left[i],x)!=NULL||strchr(right[i],x)!=NULL)return false;break; case 'u':if(strchr(right[i],x)==NULL)return false;break; case 'd':if(strchr(left[i],x)==NULL)return false;break; } } return true; } int main() { int n; cin>>n; while(n) { n--; for(int i=0;i<3;i++) { cin>>left[i]>>right[i]>>result[i]; } for(char c='A';c<='L';c++) { if(h(c)) {cout<<c<<" is the counterfeit coin and it is heavey."<<endl;break;} if(l(c)) {cout<<c<<" 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