Commit d536ccf6 by BellCodeEditor

auto save

parent 4f1cf862
Showing with 32 additions and 0 deletions
list = [1,2,3,4,5,6]
for i in range(len(list)-1):
for j in range(len(list)-i-1):
if list[j] < list[j+1]:
list[j],list[j+1] = list[j+1],list[j]
print(list)
\ No newline at end of file
import time
start_time = time.time() #开始时间 1970年1月1日0时0分0秒 到现在的总秒数
list1 = []
for a in range(0, 1000):
for b in range(0, 1000):
list1.insert(-1, 0)
end_time = time.time() #结束时间 1970年1月1日0时0分0秒 到现在的总秒数
result = end_time - start_time #代码运行时间
print('代码运行时间是:',result)
alist = [20, 17, 9, 13, 5, 6] #5
for i in range(len(alist)-1):
for j in range(len(alist)-1-i): # 0 , 1 , 2, 3, 4, 5
if alist[j] > alist[j+1]:
alist[j],alist[j+1] = alist[j+1],alist[j]
print(alist)
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