谁能告诉我我的代码有什么问题。我正在尝试创建一个游戏,让计算机猜测我输入的数字。这是我的代码:
#include <stdio.h>
#include <time.h>
#include <stdlib.h>
int main(void) {
int numberGuess = 0;
int low = 1;
int high = 100;
int computerGuess = 0;
printf("Enter a number, 1 - 100: ");
scanf("%d", &numberGuess);
while (computerGuess != numberGuess)
{
computerGuess = ((high - low) + low)/2;
printf("%d ", computerGuess);
if (numberGuess > computerGuess)
{
printf("Your guess was to low \n");
low = computerGuess+1;
}
else if (numberGuess < computerGuess)
{
printf("Your guess was to high \n");
high = computerGuess-1;
}
else if (numberGuess == computerGuess)
{
printf("Yess!! you got it!\n");
}
}
return 0;
}