思维挑战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;
}