北大OJ1013

来源:互联网 发布:阿里云数据库外网 编辑:程序博客网 时间:2024/05/29 07:11
#include<iostream>#include<cstring>using namespace std;char Left[3][7],Right[3][7],Result[3][7];bool isLight(char c){  for(int i=0;i<3;i++)  {  if(strcmp(Result[i],"even")==0)  {     if(strchr(Left[i],c)!=NULL||strchr(Right[i],c)!=NULL)  return false;  }  if(strcmp(Result[i],"up")==0)  {  if(strchr(Right[i],c)==NULL)return false;  }  if(strcmp(Result[i],"down")==0)  {  if(strchr(Left[i],c)==NULL)return false;  }  }  return true;}bool isHeavy(char c){  for(int i=0;i<3;i++)  {  if(strcmp(Result[i],"even")==0)  {     if(strchr(Left[i],c)!=NULL||strchr(Right[i],c)!=NULL)  return false;  }  if(strcmp(Result[i],"up")==0)  {  if(strchr(Left[i],c)==NULL)return false;  }  if(strcmp(Result[i],"down")==0)  {  if(strchr(Right[i],c)==NULL)return false;  }  }  return true;}int main(){ int n;cin>>n;while(n--){for(int i=0;i<3;i++)cin>>Left[i]>>Right[i]>>Result[i];        for (char c = 'A'; c <= 'L'; c++ ){        if ( isLight(c) ){             cout<<c<<" is the counterfeit coin and it is light.\n";             break;        }        if ( isHeavy(c) )        {             cout<<c<<" is the counterfeit coin and it is heavy.\n";             break;        }}}return 0;}
0 0
原创粉丝点击