http://code.bupt.edu.cn/problem/p/103/
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<stack>
#include<iostream>
using namespace std;
int main()
{
string s;
while(getline(cin,s))
{
stack<string> v;
int f=0;
int l=0;
int len=s.length();
while(l<=len-1)
{
if(s[l]==' ')
{
string tmp=s.substr(f,l-f);
f=l+1;
v.push(tmp);
l++;
}
else
l++;
}
string tmp=s.substr(f,l-f);
v.push(tmp);
int flag=0;
while(v.empty()!=true)
{
string ss=v.top();
v.pop();
if(flag==0)
{
cout<<ss;
flag++;
}
else
cout<<" "<<ss;
}
cout<<endl;
}
return 0;
}