C++编程 游戏:棒打老虎鸡吃虫

random
random
random
订阅者
10532
文章
0
评论
生活百科评论269字数 134阅读0分26秒阅读模式

#include "stdio.h"

#include "stdlib.h"文章源自玩技e族-https://www.playezu.com/240230.html

#include "time.h"文章源自玩技e族-https://www.playezu.com/240230.html

int main文章源自玩技e族-https://www.playezu.com/240230.html

 int num,input;文章源自玩技e族-https://www.playezu.com/240230.html

 char ch;文章源自玩技e族-https://www.playezu.com/240230.html

 char a[4][10]={"棒","老虎","鸡","虫"};文章源自玩技e族-https://www.playezu.com/240230.html

 srand(time(NULL));文章源自玩技e族-https://www.playezu.com/240230.html

 while(1)文章源自玩技e族-https://www.playezu.com/240230.html

  num=rand%4+1;文章源自玩技e族-https://www.playezu.com/240230.html

  printf("你出:(1.棒 2.老虎 3.鸡 4.虫)");文章源自玩技e族-https://www.playezu.com/240230.html

  scanf("%d",input);

  fflush(stdin);

  if(input+1==num || (input==4 num==1))

   printf("电脑出:%sn",a[num-1]);

   printf("你出:%sn",a[input-1]);

   printf("你赢了!n");

  else if(num+1==input || (num==4 input==1) )

   printf("电脑出:%sn",a[num-1]);

   printf("你出:%sn",a[input-1]);

   printf("你输了!n");

  else

   printf("电脑出:%sn",a[num-1]);

   printf("你出:%sn",a[input-1]);

   printf("平局!n");

  printf("还想再来一次吗?(Y/N)");

  scanf("%c",ch);

  fflush(stdin);

  if(ch=='Y' ||ch=='y')

    continue;

  else

   break;

C++编程 游戏:棒打老虎鸡吃虫插图
中国百科
 
匿名

发表评论

匿名网友
确定

拖动滑块以完成验证