#include<iostream>
#include<string>
int main()
{
using namespace std;
string str;
cin >> str;
cout << endl << str << endl;
int n = 0;
n = str.length();
for (int i = 0;i < n;i++)
{
if (tolower(str[i]) != str[i])
str[i] = towlower(str[i]);
else
str[i] = toupper(str[i]);
}
cout << str << endl;
cin.get();
cin.get();
return 0;
#include<string>
int main()
{
using namespace std;
string str;
cin >> str;
cout << endl << str << endl;
int n = 0;
n = str.length();
for (int i = 0;i < n;i++)
{
if (tolower(str[i]) != str[i])
str[i] = towlower(str[i]);
else
str[i] = toupper(str[i]);
}
cout << str << endl;
cin.get();
cin.get();
return 0;
}
c++ primer plus 第六章变成练习 第一题,有更好的思路欢迎贴出来,大家一起学习