私のコードの何が問題なのか誰にも教えてもらえますか? 入力した数字をコンピューターが推測するゲームを作成しようとしています。これが私のコードです:
#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;
}