学习了if后做的小东西!

//

//  main.m

//  aaa

//

//  Created by VincentFu on 15/7/9.

//  Copyright (c) 2015 Myo. All rights reserved.

//


#import <Foundation/Foundation.h>

#include <stdio.h>

#include <stdlib.h>


int main(int argc, const char * argv[]) {

    

    int computer = -1,player = -1;

    

    computer = arc4random_uniform(3);

    

    printf("出拳!!!!!!\n 0.剪刀 1.石头 2.\n");

    scanf("%d",&player);


    if (player ==0 ) {

        printf("你出:剪刀\n");

        

    }else if(player ==1){

        printf("你出:石头\n");

    }else if(player==2){

        printf("你出:\n");

    }

    

    

    if (computer ==0 ) {

        printf("电脑出:剪刀\n");

        

    }else if(computer ==1){

        printf("电脑出:石头\n");

    }else if(computer==2){

        printf("电脑出:\n");

    }

    

    

    if(player<0 || 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;

    }

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值