我的程序生成的数字是 999999999999999999999999999999999999。我如何让这个程序生成从 1 到 100 的数字。我如何告诉用户他们还剩多少次尝试?
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
int main()
{
int loopcount = 0;
int y = rand()%10;
int a;
printf("You have 8 chances to guess the right number. Enter your first number.");
while ((loopcount < 9) &&(y>0) &&(y<100))
{
printf("enter a number.");
scanf("%d", &a);
if (a == y){
printf(" you have guessed the correct number.");
loopcount = loopcount + 9;
break;
}
else if (a < y){
printf("the number is less than");
loopcount = loopcount + 1;
continue;
}
else if (a > y){
printf("the number is greater");
loopcount = loopcount + 1;
continue;
}
else{
printf("nothing.");
break;
}
}
system("pause");
}