#include <iostream>
#include <cctype>
using namespace std;
int main() {
char ch;
cout << "enter the text words: " << endl;
while (cin.get(ch)&&ch!='@') {
if (!isdigit(ch)) {
if (islower(ch))
cout << char(toupper(ch));
else
cout << char(tolower(ch));
}
}
return 0;
}
cctype函数库部分函数:
isdigit():如果参数是数字(0~9),则该函数返回ture;
toupper():如果参数时小写字符,则返回其大写,否则返回该参数;
tolower():如果参数时大写字符,则返回其小写,否则返回该参数;