C++ Primer Plus 6.11.1
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 | #include <iostream> #include <cctype> using namespace std; int main() { cout<< "==<<回显非数字输入,并转换小写为大写,转换大写为小写>>==\n\n" ; cout<< "请输入文本,@结束输入:\n" ; char ch; cin.get(ch); while (ch!= '@' ) { if (! isdigit (ch)) { if ( isupper (ch)) { ch= tolower (ch); } else if ( islower (ch)) { ch= toupper (ch); } cout<<ch; } cin.get(ch); } cout<< "再见!\n" ; return 0; } |

近期评论