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