大家帮忙看看这个程序
#include <stdio.h>#include <time.h>
#include <stdlib.h>
void main()
{
int user,computer;
char sure;
labal:
srand((int)time(0));
computer=rand()%(0-10);
printf("please input yur number:");
while(1)
{
scanf("%d",&user);
if(user<computer)
printf("you should input a bigger number:");
else if(user>computer)
printf("you should input a smaller number:");
else if(user==computer)
{
printf("congratulation you are right!!!\n");
printf("are you continue (Y/N):");
scanf("%c",&sure); //为什么执行到这里没有停下来等待用户输入????????
sure=toupper(sure);
while(sure!='Y'&&sure!='N')
{
putchar(7);
printf("you should input Y or N:");
scanf("%c",&sure);
sure=toupper(sure);
}
if(sure=='Y')
goto labal;
else if(sure=='N')
exit(0);
}
}
} 回车是字符 在那里再定义一个变量,用scanf存储回车键 在那句下面再加一句scanf("%c",&sure);
页:
[1]