我的代碼是:循環的立即退出時輸入不是C中的無符號++
unsigned numbers, x = 0, odds = 0;
cout << "Input numbers to find the amount of odds. " << endl;
while (x < 9999){
cin >> numbers || die("Input Error");
if (numbers % 2 == 1) {
odds++;
}
}
cout << "There are " << odds << " odds." << endl;
return 0;
我怎麼能放棄當用戶輸入對數字的非數字值的循環?先進的謝謝你。
[讀「無符號整數」使用「CIN」]的可能的複製(http://stackoverflow.com/questions/9574771/reading-unsigned-int-using-cin) – Downvoter