大神快来。为什么输入一个字符就一直循环
#include <stdio.h>int main(void)
{
int i, j; //i为密码,j验证i是否正确;
char ch; //判断;
printf("请输入密码:");
scanf("%d", &i);
printf("是否正确?y/n");
ch = getchar();
while(ch == 'n')
{
printf("请输入密码:");
scanf("%d", &i);
printf("是否正确?y/n");
ch = getchar();
continue;
}
printf("请重新输入密码:");
scanf("%d", &j);
while(j != i)
{
printf("密码有误!请重新输入\n");
scanf("%d", &j);
continue;
}
printf("密码设置成功!");
return 0;
}