Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from random import randint
- import time
- def sozdanie(a):
- file_test = open("file.txt", "w")
- for i in range(a):
- number = randint(0,10000)
- file_test.write(str(number) + '\n')
- file_test.close()
- return 0
- def vstavka(list): #Сортировка методов вставок
- p = 0
- for i in range(len(list)):
- j = i-1
- key = list[i]
- while list[j] > key and j >= 0:
- list[j+1] = list[j]
- j -= 1
- list[j+1] = key
- if (i%100) == 0:
- p+=1
- print(p, "%")
- return(list)
- def chtenie(a):
- with open("file.txt") as f:
- for line in f:
- a.append([int(x) for x in line.split()])
- return(a)
- sozdanie(10000)
- data = []
- start_chtenie = time.time()
- chtenie(data)
- stop_chtenie = time.time()
- print("prochital")
- start_sortirovka = time.time()
- vstavka(data)
- stop_sortirovka = time.time()
- print("otsortiroval")
- print((stop_chtenie-start_chtenie)*1000)
- print((stop_sortirovka-start_sortirovka)*1000)
Add Comment
Please, Sign In to add comment