Commit 2d89331e by BellCodeEditor

save project

parent 0a7b0048
Showing with 30 additions and 2 deletions
num_list=[7,9,12,4,77,90,180,3,88,3]
dh = len(num_list)
for i in range(0,dh-1):
for wsh in range(0,dh-1):
if num_list[wsh] > num_list[wsh-1]:
num_list[wsh],num_list[wsh+1] = num_list[wsh+1],num_list[wsh]
print(num_list)
\ No newline at end of file
ab=[7,9,12,4,77,90,180,3,88,3] #从小到大排序
cd = len(ab)
#用变量i表示第几轮排序
for i in range(0,cd-1):
for j in range(0,cd-1):
if ab[j] > ab[j+1]:
ab[j],ab[j+1] = ab[j+1],ab[j]
print(ab)
\ No newline at end of file
alist = [88, 75, 72, 82, 90, 85, 78, 91] ab=[7,9,12,4,77,90,180,3,88,3] #从小到大排序
\ No newline at end of file
cd = len(ab)
#用变量i表示第几轮排序
for i in range(0,cd-1):
for j in range(0,cd-1):#用变量j表示列表的索引下标
#比较大小并交换
if ab[j] < ab[j+1]:
ab[j],ab[j+1] = ab[j+1],ab[j]
print(ab)
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment