使用python高效处理字符串,直接用空格分隔,然后倒序输出即可

s = input().split(" ")
for i in s[::-1]:
    print( i , end = " " )
print()

#牛客春招刷题训练营# + 链接