#include<stdio.h>
#include<stdlib.h>
#include<time.h>
int main()
{
int computer=-1,player=-1;
srand((unsigned)time(NULL));
computer = rand()%3;
//printf("%d",computer);显示电脑出拳。
printf("请玩家出拳:\n 0.剪刀, 1.石头, 2.布\n");
scanf("%d",&player);
if(player !=0 && player !=1 && player !=2)
{printf("请遵守规则出拳!");return 0;}
if((player==0&&computer==2)||(player==1&&computer==0)||(player==2&&computer==1))
{printf("恭喜你赢了!\n");}
else if((computer==0&&player==2)||(computer==1&&player==0)||(computer==2&&player==1))
{printf("抱歉你输了!\n");}
else
{printf("平局\n");}
return 0;
} |
|