编程问题求解!!!!!!!!!

大佬们帮帮忙,刚学c没多久,这就是个猜数字程序,我想在结束后询问“是否想在玩”然后决定程序是否继续,但是它直接就开始第二轮了。。。

img

#include<stdio.h>
#include<time.h>
#include<stdlib.h>
int main(void)
{
while(1)
{
int x=1;
char y;
char n;
char choice=y;
int number;
srand(time(0));
number=rand()&10;
int inputnum=-1;
int times=0;
printf("can you guess the right number?pls enter one number!but remember you only have 4 opportunities!\n");
for(times=0;times<5;times++)
{scanf("%d",&inputnum);
if(inputnum>number)
{
printf("too big\n");
}
else if(inputnum<number)
{
printf("too small\n");
}
if(inputnum==number)
{
printf("you are right!you have guessed %d times!\n",times);
x=0;
break;
}
}
if(times<=5!=1)
{
printf("you failed!\n");
x=0;
}
printf("want to play it again?answer y or n\n");
scanf("%c",&choice);
if(choice==n)
{printf("thanks for your playing!");
break;
}
}
}

scanf("%c",&choice);会接收到上一个scanf遗留的\n换行符。你可以改成scanf("\n%c",&choice);