last lab
This commit is contained in:
21
labPython/lab7/sort2.py
Executable file
21
labPython/lab7/sort2.py
Executable file
@@ -0,0 +1,21 @@
|
||||
from os import replace
|
||||
import sort_methods
|
||||
from random import randint
|
||||
|
||||
array = [randint(-100, 100) for _ in range(30)]
|
||||
with open("input.txt", "w") as inputFile:
|
||||
for element in array:
|
||||
inputFile.write(f"{element}\n")
|
||||
listOfNumber = []
|
||||
with open("input.txt", "r") as inputFile:
|
||||
for string in inputFile:
|
||||
listOfNumber.append(int(string.replace("\n", "")))
|
||||
print(listOfNumber)
|
||||
listOfNumber = sort_methods.bubble_sort(listOfNumber)
|
||||
|
||||
with open("output.txt", "w") as outputFile:
|
||||
for element in listOfNumber:
|
||||
outputFile.write(f"{element}\n")
|
||||
|
||||
print("Пузырьковая сортировка")
|
||||
print("сложность сортировки O(n^2)")
|
||||
Reference in New Issue
Block a user