石头剪子布

题目描述:
大家小时候都玩过石头剪子布的游戏吧,出石头的人赢出剪子的人,
出剪子的人赢出布的人,出布的人赢出石头的人,如果两个人出的一样,则打平。
飞燕姐姐和婷婷玩石头剪子布的游戏,请你写一个程序判断一下谁赢了

输入:
石头用stone表示,剪子用scissors表示,布用cloth表示
飞燕姐姐和婷婷出的用空格隔开
以EOF结束

输出:
飞燕姐姐赢了则输出yzfy wins!
婷婷赢了则输出wtthappy wins!
打平则输出The game ends in a draw.
谁出错了就判另一方赢,大家都出错了就和

样例输入:
stone cloth
stone stone
stone scissors
scissor stone
stome scissor

样例输出:
wtthappy wins!
The game ends in a draw.
yzfy wins!
wtthappy wins!
The game ends in a draw.

其它:
题目提供:wtthappy
  1. #define PB_ID ct10_3
  2. #define CP_GCC
  3. #include<stdio.h>
  4. #include<string.h>
  5. #define MAX 10
  6. int isRight(char* str)
  7. {
  8.     if(!strcmp(str,"stone") || !strcmp(str,"scissors") || !strcmp(str,"cloth"))
  9.         return 1;
  10.     else
  11.         return 0;
  12. }
  13. int main()
  14. {
  15.     char yzfy[MAX],wtthappy[MAX];
  16.     while(scanf("%s%s",yzfy,wtthappy)!=EOF){
  17.         if((!isRight(yzfy) && !isRight(wtthappy)) || !strcmp(yzfy,wtthappy)){
  18.             printf("The game ends in a draw./n");
  19.             continue;
  20.           }
  21.         if(!isRight(yzfy) && isRight(wtthappy)){
  22.             printf("wtthappy wins!/n");
  23.             continue;
  24.         }
  25.         if( isRight(yzfy) && !isRight(wtthappy)){
  26.             printf("yzfy wins!/n");
  27.             continue;
  28.         }
  29.         if( !strcmp(yzfy,"stone"))
  30.             if(!strcmp(wtthappy,"cloth"))
  31.                 printf("wtthappy wins!/n");
  32.             else
  33.                 printf("yzfy wins!/n");
  34.         if( !strcmp(yzfy,"cloth"))
  35.             if(!strcmp(wtthappy,"scissors"))
  36.                 printf("wtthappy wins!/n");
  37.             else
  38.                 printf("yzfy wins!/n");
  39.         if( !strcmp(yzfy,"scissors"))
  40.             if(!strcmp(wtthappy,"stone"))
  41.                 printf("wtthappy wins!/n");
  42.             else
  43.                 printf("yzfy wins!/n");
  44.     }
  45.     return 0;
  46. }
<script type=text/javascript> </script> <script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type=text/javascript> </script>
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值