wu


私信TA

用户名:cncfvc

访问量:215702

签 名:

读研狗没有时间刷题了~~

等  级
排  名 2
经  验 36074
参赛次数 8
文章发表 265
年  龄 25
在职情况 学生
学  校 电子科技大学
专  业 通信工程

  自我简介:

写代码 真好玩 ~


利用剪刀石头布之间的逻辑关系 以及枚举类型enum 就可以很方便地解决问题

参考代码:

#include<iostream>
using namespace std;
int main()
{
   enum caiquan{shitou,bu,jiandao};
   int a,b;
   while(cin>>a>>b)
   {
   	 if(a==shitou&&b==jiandao||a==jiandao&&b==bu||a==bu&&b==shitou)
   	 cout<<"1"<<endl;
   	 else if(b==shitou&&a==jiandao||b==jiandao&&a==bu||b==bu&&a==shitou)
   	 cout<<"-1"<<endl;
   	 else
   	 cout<<"0"<<endl;
   	 
   }
   return 0;
}


 

0.0分

3 人评分

  评论区