#include <stdio.h>
#include <stdlib.h>
Int main(int argc,const char * argv[]){
//制定规则
/*
输赢规则:
剪刀、石头、布分别用 0、1、2代替,按照剪刀赢布,布赢石头,石头赢剪刀的规则进行。
*/
int computer = -1,player = -1;
Computer = arc4random_uniform(3);
//产生0,1,2之间的额随机数
printf("请出拳,o代表剪刀,1代表石头,2代表布");
scanf("%d",&player);
if(player<0||player>2){
printf("请按套路出拳");
}
if((player==0&&computer==2)||
(player==1&&computer==0)||
(player==2&&computer==1)){
Printf("恭喜你赢了");
}else if ((computer==0&&player==2)||
(computer==1&&player==0)||
(computer==2&&player==1)){
printf("你输了\n");
}else{
Printf("平局");
} |
|