下面的程序为什么要输入两个值后开始判断,而且当输入n或N时exit(0)怎么不退出程序?
#include <stdlib.h>#include <stdio.h>
#include <time.h>
int val( )
{int i;
srand( (unsigned)time( NULL ) );
i = rand()%100+1;
return(i);
}
main()
{int i,m;
char w;
printf("please guess a number between 1 to 100:");
scanf("%d\n",&m);
i=val();
do
{if(m>i)
{printf("too high,guess again!\n");
scanf("%d",&m);}
if(m<i)
{printf("too low,guess again!\n");
scanf("%d",&m);}
}while(m!=i);
printf("good,would you like to play the game again? Y or N\n");
w=getchar();
getchar();
if(w=='n'||w=='N')
exit(0);
else
main();
}