#include"stdio.h"
#include"stdlib.h"
void main()
{
int problem,guess=1,a;
char ch;
problem=(int)(rand()%899+1);
scanf("%f%d",&ch,&guess);
for(a=0;ch!='n';a++)
for(a=0;guess==problem;a++)
{if(guess>problem)
printf("too high");
if(guess<problem)
printf("too low");
scanf("%d",&guess);
}
printf("%d",problem);
scanf("%f",&ch);
}为什么运行不起来 scanf("%f%d",&ch,&guess);只输入完这个语句够,界面就不动了

c语言问题求大神指导!!
- 写回答
- 好问题 0 提建议
- 关注问题
- 邀请回答
-
6条回答 默认 最新
- 天命王子 2015-07-14 13:07关注
帮你改了一下,大概你要的是这种效果吧。
#include"stdio.h" #include"stdlib.h" int main() { int problem,guess=1; char ch; problem=(int)(rand()%899+1); scanf("%c%d",&ch,&guess); for(;ch!='n';){ for(;guess!=problem;) {if(guess>problem) printf("too high\n"); if(guess<problem) printf("too low\n"); scanf("%d",&guess); } printf("You are right!The number is %d\n",problem); scanf("%c",&ch); } return 0; }
本回答被题主选为最佳回答 , 对您是否有帮助呢?解决 无用评论 打赏 举报