#include <iostream>
#include <string>
using namespace std;
string str;
void reverse(int begin,int end)
{
while(begin<end)
{
str[begin] = str[begin]^str[end];
str[end] = str[begin]^str[end];
str[begin] = str[begin]^str[end];
begin++;
end--;
}
}
int main()
{
int i,j;
while(getline(cin,str))
{
int len = str.length();
int begin,end;
i = 0;
while(i<len)
{
begin = i;
while(i<len&&str[i]!=' ')
i++;
end = i-1;
reverse(begin,end);
i++;
}
reverse(0,len-1);
cout << str << endl;
}
cout << "Hello world!" << endl;
return 0;
}
例如:I am zhang san. 输出:san. zhang am I;