- #include <stdio.h>
- #include <stdlib.h> // arc4random_uniform(<#u_int32_t#>) 的头文件
- int main(int argc, const char * argv[]) {
- int player = -1 ,computer = -1;
- computer = arc4random_uniform(3);
- // printf ("%d\n",computer);
- printf("请出拳: 0.剪刀 1.石头 2.布\n");
- scanf("%d",&player);
- if(player < 0 || player > 3){
- printf("请按套路出拳\n");
- }
- 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;
- }
复制代码
|
|