#include<stdlib.h>
#include<time.h>
main()
{
char A;
int m, g;
do
{
srand(time(NULL));
m=(rand()%1000)+1;
printf("I have a number between 1 and 1000\n");
printf("Can you guess my number?\n");
printf("Please type your first guess.\n");
scanf("%d", &g);
while(g!=m)
{
if(g<m)
printf("Too low.Try again.\n");
else
printf("Too high.Try again.\n");
scanf("%d", &g);
}
printf("Excellent!You guessed the number!\n");
printf("Would you like to play again(y or n)?\n");
scanf("%c", &A);
}
while(A=='y');
system("pause");
return 0;
}
其中scanf("%c", &A);一句总是不执行,循环一次程序就结束了
请高手看看是怎么回事,谢谢