Skip to content

Commit 17e1c10

Browse files
单词倒排
1 parent 5e34a98 commit 17e1c10

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

newcoder/HJ31.PY

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
'''
2+
Descripttion: 单词倒排
3+
version: 1
4+
Author: Jason
5+
Date: 2020-11-18 13:45:07
6+
LastEditors: Jason
7+
LastEditTime: 2020-11-18 13:46:31
8+
'''
9+
s_source = input()
10+
res = list()
11+
push_flag = False
12+
s_temp = ''
13+
for each_chr in s_source:
14+
if each_chr.isalpha():
15+
s_temp += each_chr
16+
push_flag = False
17+
else:
18+
if not push_flag and s_temp.isalpha():
19+
res.append(s_temp)
20+
push_flag = True
21+
s_temp = ''
22+
if not push_flag and s_temp:
23+
res.append(s_temp)
24+
print(" ".join(res[::-1]))

0 commit comments

Comments
 (0)