#include<iostream> #include<cstdio> #include<cstring> using namespace std; int mycmp(char s1[],char s2[],int len)//自定义的字符数组比较 { int flag=1; if(strlen(s2)!=len)flag=0; for(int i=0;i<len&&flag;i++) if(s1[i]!=s2[i]) { flag=0; } return flag; } int main(void) { // int n=0; // cin>>n;//获取测试次数 // getchar();//'\n'的处理 for(int i=0;i<1;i++) { char test_left[3][6],test_right[3][6],result[3][6];//分别表示左重,右重,以及大小关系 int result_number[3]; int len[3]; int len_result[3]; for(int j=0;j<3;j++) { int h=0; while(scanf("%c",&test_left[j][h])!=EOF&&test_left[j][h]!=' ') { h++; } h=0; while(scanf("%c",&test_right[j][h])!=EOF&&test_right[j][h]!=' ') { h++; } int k=0; while(scanf("%c",&result[j][k])!=EOF&&result[j][k]!='\n') { k++; } len_result[j]=k; len[j]=h; }//以上for中为读入数据 for(int i=0;i<3;i++) { if(mycmp(result[i],"up",len_result[i])) { result_number[i]=1; } else if(mycmp(result[i],"down",len_result[i])) { result_number[i]=-1; } else if(mycmp(result[i],"even",len_result[i])) { result_number[i]=0; } }//将对应大小关系转化为数字便于后序比较 // cout<<"result:"<<endl; // for(int i=0;i<3;i++) // cout<<result_number[i]<<endl; /*上述为读入数据*/ /*枚举各种情况*/ int m; int is_heavy=-1; for(m=0;m<12&&is_heavy==-1;m++) { /*假币重时*/ for(int line=0;line<3&&is_heavy==-1;line++) { int sum_left=0; int sum_right=0; // cout<<test_left[line]; for(int i=0;i<len[line];i++) { if(test_left[line][i]==(char)(m+int('A'))) { sum_left++; }//左边 if(test_right[line][i]==(char)(m+int('A'))) { sum_right++; }//右边 }//判断是否为假设的假币并对大小处理; // cout<<"heavy--"<<(char)(m+int('A'))<<":"; // cout<<line<<" : "<<sum_left<<" "<<sum_right<<" "; if(sum_left-sum_right!=result_number[line]) { sum_left=0; sum_right=0; break; }//判断是否满足对应结果,不满足则结束本轮 if(line==2) { is_heavy=1; }//到最后时没有不满足,则说明成立 sum_left=0; sum_right=0; } // cout<<endl; /*假币轻*/ for(int line=0;line<3&&is_heavy==-1;line++) { int sum_left=0; int sum_right=0; for(int i=0;i<len[line];i++) { if(test_left[line][i]==(char)(m+int('A'))) { sum_left--; } if(test_right[line][i]==(char)(m+int('A'))) { sum_right--; } } // cout<<"light--"<<(char)(m+int('A'))<<" :"; // cout<<line<<" : "<<sum_left<<" "<<sum_right<<" "; // cout<<"number "<<result_number[line]; if(sum_left-sum_right!=result_number[line]) { sum_left=0; sum_right=0; break; } if(line==2) { is_heavy=0; } sum_left=0; sum_right=0; } // cout<<endl; } if(is_heavy==0)cout<<(char)(m+int('A')-1)<<" is the counterfeit coin and it is light."; else if(is_heavy==1) cout<<(char)(m+int('A')-1)<<" is the counterfeit coin and it is heavy."; } return 0; }