#include <iostream>
using namespace std;
namespace Myspace {
string fun(string str);
}
using namespace Myspace;
string Myspace::fun(string str){
int i = 0;
int j = 0;
int k = 0;
int len = str.length();
while(k<len){
while(j!=' ' && j<len)
j++;
k = j;
while(k==' ' && k<len)
k++;
j--;
while(i<j){
char t = str.at(i);
str.at(i) = str.at(j);
str.at(j) = t;
i++;
j--;
}
i = k;
j = k;
}
return str;
}
int main()
{
cout << "输入一个字符串:" ;
string str;
getline(cin,str);
str = fun(str);
cout << "逆置后 : ";
cout << str << endl;
return 0;
}