#include <stdio.h>
int main()
{
int initial = 50, downpoint = 0, highpoint = 100;
char ch;
printf("Please pick a number and don't change it in your mind.\n");
printf("Let me guess, if it is %d or higher or lower than it?\n", initial);
printf("If it's higher than the number you've chosen type down 'h', if it's lower type down 'l' and if it's right type down 'y'.\n");
while ((ch = getchar()) != 'y')
{
if (ch == 'h')
highpoint = initial;
else if (ch == 'l')
downpoint = initial;
initial = (highpoint + downpoint) / 2;
getchar(); // 清除回车符
printf("Then if %d is your number?\n", initial);
}
printf("I found your number! It's %d.\n", initial);
return 0;
}
07-24
343
08-07