新手上路,跪求各位大牛解惑!!!!
这是一个猜数的题,但为什么开始每次除了定义的电脑数,还要输入两次才开始判断啊?而且相近的数也只会显示“Too small”?该怎么办?#include<stdio.h>
int main()
{
int num,n,yournumber,count=0,flag=0;
printf("请输入100以内的正整数和次数:\n");
scanf("%d %d\n",&num,&n);
scanf("%d\n",&yournumber);
while(yournumber>=0)
{
count++;
if(count>n)
break;
if(num==yournumber)
{
flag=1;
break;
}
else if(num>yournumber)
{
printf("Too small\n");}
else
{
printf("Too big\n");}
scanf("%d\n",&yournumber);
}
if(flag==0)
printf("Game over\n");
else if(count==1)
printf("Bingo!\n");
else if(count<=3)
printf("Lucky You!\n");
else
printf("Good Guess!\n");
return 0;
}