c语言猜拳游戏分析
发布网友
发布时间:2023-07-13 23:47
我来回答
共1个回答
热心网友
时间:2023-09-26 02:55
#include<stdio.h>
#include<math.h>
main()
{char c1;
int i,j;
do{
printf("Please input :");
scanf("%d",&i);
if(i<1||i>3){printf("Input error!\nPlease input again!\n");continue;}
j=rand()%3+1;
printf("%d\n",j);
if(i==j)printf("Ping Ju!\n");else
if((i-j)==1)printf("YOU WIN!\n");else
if(i==1&&j==3)printf("YOU WIN!\n");else
printf("YOU LOSE!\n");
printf("Replay?(Y/N)");
scanf("%c",&c1);
if(c1=='n'||c1=='N')break;
}while(c1=='y'||c1=='Y');
printf("Welcome to play again!\nAny key Quit...");
getch();putchar('\n');
}