这种情况是怎么回事,为什么显示未定义,可是我是按着书本来的,是要改动一些东西吗
#include <time.h>
#include <stdlib.h>
补充一点,srand函数使用需要调用rand函数
有几个头文件没有引入,还有你这不是坑人吗?a是那个生成的数,b才是你输入的,然后a>b的时候,你输出“大了”,a<b的时候,你输出“小了”??还有,不是应该只有6次机会是吧,我怎么可以一直输入的?
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
int main()
{
int a, b, c;
c = 6;
srand((unsigned)time(NULL));
a = rand() % 90 + 10;
while(c >= 0)
{
c--;
scanf("%d", &b);
if (a > b)
printf("小了,还剩下%d次机会,请继续\n", c);
if (a < b)
printf("大了,还剩下%d次机会,请继续\n", c);
if (a == b)
{
printf("恭喜你答对了");
break;
}
}
return 0;
}