1 #include <iostream>
2 using namespace std;
3
4 void reverse(string &s, int beg, int end)
5 {
6 if (beg >= end)
7 return;
8
9 while(beg < end)
10 {
11 char c = s[beg];
12 s[beg] = s[end];
13 s[end] = c;
14 beg++;
15 end--;
16 }
17 }
18
19 int main()
20 {
21 string s;
22 while(getline(cin, s))
23 {
24 reverse(s, 0, s.size()-1);
25 int start = 0;
26 for(int i = 0; i < s.size(); i++)
27 {
28 if (s[i] == ' ')
29 {
30 reverse(s, start, i - 1);
31 start = i + 1;
32 }
33 }
34
35 reverse(s, start, s.size() - 1);
36
37 cout << s << endl;
38 }
39 }