题解 | #字符串排序#
字符串排序
https://www.nowcoder.com/practice/5af18ba2eb45443aa91a11e848aa6723
import sys python 冒泡排序 str_n = [] n = int(input()) while True: try: str_n.append(input()) except: break for i in range(0, n): s_flag = False for j in range(0, n - i - 1): if str_n[j] > str_n[j + 1]: str_n[j + 1], str_n[j] = str_n[j], str_n[j + 1] s_flag = True if not s_flag: #排序完成早停 break for i in str_n: print(i)