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

#include "stdio.h"

#include "stdlib.h"

#include "time.h"

int main

 int num,input;

 char ch;

 char a[4][10]={"棒","老虎","鸡","虫"};

 srand(time(NULL));

 while(1)

  num=rand%4+1;

  printf("你出:(1.棒 2.老虎 3.鸡 4.虫)");

  scanf("%d",input);

  fflush(stdin);

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

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

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

   printf("你赢了!\n");

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

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

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

   printf("你输了!\n");

  else

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

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

   printf("平局!\n");

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

  scanf("%c",ch);

  fflush(stdin);

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

    continue;

  else

   break;

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

你可能想看:
标签: printfnuminput
分享给朋友: