第四章例4-5

/* 简单的猜数游戏 */
#include<stdio.h>
int main(void)
{
    int mynumber=38;
    int count=0,yournumber;
    for(count=1;count<=5;count++) {
        printf("Input your number:");
        scanf_s("%d",&yournumber);
        if(yournumber==mynumber){
            printf("Ok!you are right!\n");
            break;
        }
        else
            if(yournumber>mynumber)
                printf("Sorry!your number is bigger than my number!\n");
            else
                printf("Sorry!your number is smaller than my number!\n");
    }
    printf("Game is over!\n");

    return 0;

}

posted @ 2013-10-05 22:38  刘睿1994  阅读(109)  评论(0编辑  收藏  举报