我想问用平均数比大小来猜数字那个平均数怎么打?

http://img.mukewang.com/581f4cf000017e6209470461.jpg

#include<stdio.h>

#include<math.h>

int main(void)

{

char ch;

int a=50,i=0,c;

int b=100;

printf("Pick an integer from 1 to 100. I will try to guess it.\n");

printf("Respond with an 'b' if my quess is big and with\n");

printf("an '1' if it is little.\n");

printf("Also,Resond an 'y' if it is right.\n");

printf("Un...is your number 50?\n");

while((ch=getchar())!='y')

{

if(ch=='1')

{ c=(a+b)/2;

????????

printf("Well,then,is it %d?\n",c);

}

else if(ch=='b')

{c=(a+i)/2;

c=(a+i)/2;

????????

printf("Well,then,is it %d?\n",c);

}

else

{

printf("Sorry,I understand only 'b','1'or'y'.\n");

}

while(getchar()!='\n')

continue;

}

printf("I know I could do it!\n");

return 0;

}


慕粉4170453
浏览 1247回答 0
0回答
打开App,查看更多内容
随时随地看视频慕课网APP