#include <iostream> // 没用到
#include <cstdlib>
#include <cmath> // 没用到
#include <ctime>
using namespace std; // 没用到
int main ()
{
int guess;
char answ; // 没用到
srand (time (0));
for (int i = 0; i < 100; i++) // 只能 loop 100 次吗?
{
int random = rand(); // 不应该放在 loop 里面
int num = ((random % 100) + 1);
printf("Guess a number between 1 to 100:\n");
scanf("%d", guess); 应该用 &guess
if (guess > num)
{
printf("the number you guess is too smaller. Try again??\n");
continue;
}
if (guess < num)
{
printf("the number you guess is too bigger. Try again??\n");
continue;
}
else if (guess = num) // 应该是 guess == num
{
printf("congrulation !!");
break;
}
}
return 0;
}
欢迎光临 JBTALKS.CC (https://www.jbtalks.cc/) | Powered by Discuz! X2.5 |