一个C++小题目
编写一个程序,读取键盘输入,知道遇到@符号为止,并回显输入,同时将大写字符转换为小写,将小写字母转换为大写。
下面这是一份答案,这份答案有什么不足,或者还有个更好的思路吗?
#include <iostream>#include <cctype>int main(){ using namespace std; char ch; cout << "请输入:"; cin.get(ch); while (ch != '@') { if (islower(ch)) ch = toupper(ch); else if (isupper(ch)) ch = tolower(ch); cout << ch; cin.get(ch); } return 0;}