Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Перше завдання (4 варіант)
- array = [2, 15, 42, 7, 12, 21, 3, 25]
- print("\033[52;1;118mПочатковий масив:", array, "\033[0m")
- n = len(array)
- p = n - 1
- while p > 0:
- m = 0
- for i in range(1, p + 1):
- if array[i] > array[m]:
- m = i
- highlighted_array = []
- for i, num in enumerate(array):
- if i == m or i == p:
- highlighted_array.append("\033[1;33;1m{}\033[0m".format(num))
- else:
- highlighted_array.append(str(num))
- print(' '.join(highlighted_array))
- u = array[m]
- array[m] = array[p]
- array[p] = u
- p = p - 1
- print("\033[52;1;118mМасив після сортування:", array, "\033[0m")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement