怎么做到输入Y继续循环,输入N退出循环
下面的输入N可以退出循环,但是输入任意都能继续执行循环,怎么才能做到输入Y才能继续循环,输入其他都不能?int Input(SqList &L,int n){
int i=0;
char j,a[10];
while(j!='n'&&j!='N'){
printf("\t编号:");
scanf("\t%d",&L.elem[n+i].num);
printf("\t姓名:");
scanf("\t%s",&L.elem[n+i].name);
printf("\t年龄:");
scanf("\t%s",&L.elem[n+i].age);
printf("\t电话号码:");
scanf("\t%s",&L.elem[n+i].phone);
printf("\t通讯住址:");
scanf("\t%s",&L.elem[n+i].adds);
printf("\t电子邮箱:");
scanf("\t%s",&L.elem[n+i].email);
gets(a);
printf("\n\t是否继续添加 (Y/N)");
scanf("\t%c",&j);
i++;
}
return(n+i);
}