应该先把回车给吸收掉,然后接受“y”或“n”..............
#include "stdio.h"
main()
{
int Password,i=0;
printf("=======This is a Number Guess Game!!=====\n\n");
printf("Please input your password!\n");
scanf("%d",&Password);
while(Password!=1986)
{
i++;
if(i==3)
{
printf("Sorry,you are three times wrong!");
return -1;
}
printf("Please input the corret password!!\n");
scanf("%d",&Password);
}
char c;
printf("Pass.Do you want to start?\n\n\nStart press Y else N.\n\n");
c=getchar();c=getchar();
if(c=='Y'||c=='y')
printf("Game start!");
else if(c=='N'||c=='n')
printf("Press any key to quit....");
else if(c!='Y'||c=='N'||c=='y'||c=='n')
printf("Please press Y or N!!");
getchar();
return 0;
}
C-FREE3.5