BeBreave 2015-07-14 12:20 采纳率: 40%
浏览 1496
已采纳

c语言问题求大神指导!!

#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);只输入完这个语句够,界面就不动了

  • 写回答

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;
     }
    
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(5条)

报告相同问题?