Commit 49bd11e5 by BellCodeEditor

auto save

parent f5bf03ae
Showing with 33 additions and 1 deletions
import time
aa=time.time()
# print(a)
list1 = []
for a in range(0, 1000):
for b in range(0, 1000):
list1.append(0)
bb=time.time()
print(bb-aa)
'''
#冒泡排序的代码实现原理
def b_s(l):
n = len(l)
#i表示第几轮排序
for i in range(0,n-1):
#j表示列表的下标
for j in range(0,n-1)
#比大小
if l[j]>l[j+1]:
l[j],l[j+1] = l[j+1],l[j]
'''
#输入n个正整数存储到一个列表中,按从小到大排序
num_list = []
n = int(input("请输入数字个数:"))
for i in range(n):
num = int(input("输入第"+str(i+1)+"个数字"))
num_list.append(num)
#冒泡排序
for i in range(n):
for j in range(n-1-i):
if num_list[j]>num_list[j+1]:
num_list[j],num_list[j+1] = num_list[j+1],num_list[j]
print(num_list)
print(num_list)
......@@ -8,5 +8,6 @@ for i in range(n):
for j in range(n-1-i):
if num_list[j] > num_list[j+1]:
num_list[j],num_list[j+1] = num_list[j+1],num_list[j]
print(num_list)
print(num_list)
\ 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