class Solution {
public:
string change(string s) {
int len2 = s.size();
string ret;
for (int i = 0; i < len2; i++) {
if (s[i] >= 'a' && s[i] <= 'z') {
ret += (s[i] - 32);
} else {
ret += (s[i] + 32);
}
}
return ret;
}
string trans(string s, int n) {
int len = s.size();
if (len == 0) {
return "";
}
string ret = "";
while(s.find_last_of(' ') != -1) {
int pos = s.find_last_of(' ');
string tempStr = s.substr(pos + 1);
int lenTempStr = tempStr.size();
ret += change(tempStr);
ret += " ";
s = s.substr(0, pos);
}
ret += change(s);
return ret;
}
};