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”退出程序并且没有其他字母。Broken Do/While Loop
是什么'again'? – squiguy
它在while循环中变化... –
顺便说一句,你不应该写'} while(again!='N')'? – rodrigo