#include<stdio.h>
#include<stdlib.h>
#include<time.h>
int main()
{
int guessnum,inputnum,count = 0;
//srand(time(0));//加入此行将变成真正的随机数
guessnum = rand() % 1000+1;
do
{
printf(“第%d次,输入1至1000内的整数:”,++count);
scanf("%d",& inputnum);
if(guessnum<inputnum)
printf(“猜大了\n”);
else if(guessnum>inputnum)
printf(“猜小了\n”);
} while(guessnum!=inputnum);
printf(“猜中! \n”);
return 0;
}
答案:42
猜数代码
最新推荐文章于 2023-12-02 16:09:46 发布