题目:

示例一:
9
cap
to
cat
card
two
too
up
boat
boot
输出:
boat
boot
cap
card
cat
to
too
two
up
解题方法:
n = int(input())
li = []
# 循环接收n个字符串,并添加到列表li里
for i in range(n):
li.append(input())
# 将列表li重新排序,并依次输出
for i in sorted(li):
print(i)
最后
以上就是深情金毛最近收集整理的关于牛客网HJ14 字符串排序Python3解法的全部内容,更多相关牛客网HJ14内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复