char again;
do {
counter = 0;
while (counter < 3) {
printf("Please enter a number: ");
scanf("%d", &num);
counter++;
sum += num;
}
if (counter == 3) {
printf("Would you like to continue? [Y]Yes [N]No:");
scanf("%c", &again);
}
}while (again == 'Y');
我似乎无法弄清楚为什么这不起作用。如果我输入 Y 它会中断,如果我输入 N 它会中断。我需要循环直到用户输入“N”退出程序并且没有其他字母。