Commit f4f96936 by BellCodeEditor

save project

parent 92449b0c
Showing with 83 additions and 5 deletions
list1 = [] # list1 = []
for a in range(0, 1000): # for a in range(0, 1000):
for b in range(0, 1000): # for b in range(0, 1000):
list1.insert(0, 0) # list1.insert(0, 0)
\ No newline at end of file
# import time
# start_time = time.time()
# list1 = []
# print('开始时间为',start_time)
# for a in range(0, 1000):
# for b in range(0, 1000):
# list1.insert(-1,0)
# end_time = time.time()
# print('结束时间为',end_time)
# result = end_time - start_time
# print('总耗时',result)
# import time
# start_time = time.time()
# print('开始时间为',start_time)
# for a in range(0,1001):
# for b in range(0,1001):
# c = 1000 - a - b
# if a**2 + b**2 == c**2:
# print('a b c的值分别为:',a, b, c)
# end_time = time.time()
# print('结束时间为',end_time)
# result = end_time - start_time
# print('总耗时',result)
alist = [12,15,20,15,34,66,17,9,13,8,611,55,88,564356,484,989,48,94,894,87,864,564564,54,56,454,89]
n = len(alist)
for i in range(0,n-1):
for j in range(0,n-1):
if alist[j] > alist[j + 1]:
alist[j], alist[j + 1] = alist[j + 1], alist[j]
print(alist)
# def bubble_sort(l):
# for i in range(len(lst)):
# is_sorted = True
# unsorted_border = (len(lst) - i - 1) if i == 0 else unsorted_border
# for j in range(unsorted_border):
# if l[j] > l[j + 1]:
# print(l)
# is_sorted = False
# l[j],l[j+1]=l[j+1],l[j]
# lastIndex = j
# unsorted_border = lastIndex
# if is_sorted:
# break
# lst = [5,8,9,64,59,4554,54,984,4,4,7,489,489,4,84]
# bubble_sort((lst))
\ No newline at end of file
def mao_pao(num_list):
num_len = len(num_list)
for j in range(num_len):
sign = False
for i in range(num_len - 1 - j):
if a[i] > a[i+1]:
a[i],a[i+1] = a[i+1],a[i]
sign = True
if not sign:
break
if __name__ == '__main__':
a = [1,3,4,2,6,9,12,3,22]
mao_pao(a)
print(a)
\ 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