#include <stdio.h>
#include <stdlib.h>
#include <time.h>
int main()
{
srand(time(0));
int a=rand()%100+1;//rand()的作用为随机得到一个整数
int n=0;
int b;
printf("我们已经准备好了一个随机的一到一百的数。\n");
do{
printf("请输入你猜的数字:\n");
scanf("%d",&b);
n++;
if(a>b){
printf("你猜的数字小了");
}else if(a<b){
printf("你猜的数字大了");
}
}while(a!=b);
printf("恭喜你,用%d次就猜对了!",n);
return 0;
}
猜数范围一到一百
最新推荐文章于 2024-07-25 22:24:14 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)