思维挑战10:猜数游戏

思维挑战10:猜数游戏

计算机随即给出0~99之间的一个整数,每猜一次,计算机都会告诉你大还是小了,直到才出来为止。

//C035
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
int main()
{
    int a,b;
    srand((unsigned)time(NULL));    //srand 初始化随机种子数
    a=rand()%100;   //输出一个0~99之间的随机数
    
    while(1)    //不断循环输入
    {
        scanf("%d",&b);
        if(b>a)
        printf("大啦\n");
        if(a>b)
        printf("小啦\n");
        if(a==b)
        {
            printf("恭喜你!");
            break;
    }
    }
    system("pause");
    return 0;
}
发布了33 篇原创文章 · 获赞 2 · 访问量 960

猜你喜欢

转载自blog.csdn.net/Btbsja/article/details/104312213