在系统设定数字的前提下加入随机数系统进行更加具有不确定性的猜测,提升神秘性。
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
int main ()
{
int x,y;
srand(time(0));
y=rand()%100+10;//在10到100内随机生成数字//
printf (“please input anyone to start.\n”);
l:scanf ("%d",&x);
if (x<y)
{
printf (“small\n”);
}
else if (x>y)
{
printf (“big\n”);
}
else printf (“right\n”);
goto l;
return 0;
}
随机数猜大小
最新推荐文章于 2022-10-15 20:11:36 发布