http://ac.jobdu.com/problem.php?pid=1361
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;
int main()
{
char str[100000];
while(gets(str))
{
int len,i,j;
len=strlen(str);
reverse(str,str+len);
for(i=j=0;j<len;++j)
{
if(str[j]==' ')
{
reverse(str+i,str+j);
i=j+1;
}
}
reverse(str+i,str+j);
puts(str);
}
return 0;
}