1-noskipws,不舍弃空白字符
noskipws
2-tolower,转小写字符
3-cin.eof() 结束符
cin.eof()
4-isupper(), 是否是大写字符
5-cin连续输入
int main(void) { int i, j; std::cin >> i >> j; if (j == 0) throw std::runtime_error("divisor is 0"); std::cout << i / j << std::endl; return 0; }
6-runtime_error
int main(void) { for (int i, j; cout << "Input two integers:\n", cin >> i >> j; ) { try { if (j == 0) throw runtime_error("divisor is 0"); cout << i / j << endl; } catch (runtime_error err) { cout << err.what() << "\nTry again? Enter y or n" << endl; char c; cin >> c; if (!cin || c == 'n') break; } } return 0; }