"""
1.7 编程基础之字符串 27 单词翻转 4分
http://noi.openjudge.cn/ch0107/24/
https://blog.csdn.net/hy_696/article/details/106412888
https://blog.csdn.net/m0_43456002/article/details/102729230
LeetCode--最后一个单词的长度(python版)
https://www.jianshu.com/p/e45152efc507
python反转list的三种方法
https://blog.csdn.net/qq_37969201/article/details/80406726
"""
a=input().split()
a=list(a)
lena=len(a)
i=0
while i<lena-1:
#print(str(list(reversed(a[i])))+",",end=' ')
print( str(a[i][: :-1]),end=' ')
i+=1
print( str(a[lena-1][: :-1]))
C++代码:
/*
1.7编程基础之字符串_27单词翻转04
http://noi.openjudge.cn/ch0107/27/
*/
#include<iostream>
#include<cstring>
#include<string>
using namespace std;
string a;
void Reverse(int lft,int r)
{
char x;
for(int i=lft,j=r;i<j;i++,j--)
{
x=a[i];
a[i]=a[j];
a[j]=x;
}
}
int main()
{
int n,i;
getline(cin,a);
int lena=0;
for(i=0;i<a.length();i++)
{
if(a[i]==' ')
{
Reverse(lena,i-1);
lena=i+1;
}
if(i==a.length()-1)
{
Reverse(lena,i);
lena=i+1;
}
}
cout<<a<<endl;
return 0;
}