【发布时间】:2016-01-19 13:17:10
【问题描述】:
我的代码是:
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;
当用户输入数字的非数字值时,如何退出循环?提前谢谢你。
【问题讨论】: