mirror of
https://github.com/krahets/hello-algo.git
synced 2025-07-07 06:44:57 +08:00
Format C, C++, C#, Go, Java, Python, Rust code.
This commit is contained in:
@ -46,7 +46,7 @@ def bubble_sort(nums: list[int]) -> int:
|
||||
count = 0 # 计数器
|
||||
# 外循环:未排序区间为 [0, i]
|
||||
for i in range(len(nums) - 1, 0, -1):
|
||||
# 内循环:将未排序区间 [0, i] 中的最大元素交换至该区间的最右端
|
||||
# 内循环:将未排序区间 [0, i] 中的最大元素交换至该区间的最右端
|
||||
for j in range(i):
|
||||
if nums[j] > nums[j + 1]:
|
||||
# 交换 nums[j] 与 nums[j + 1]
|
||||
|
Reference in New Issue
Block a user