Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from random import *
- from sys import stdin
- a = list(map(int, stdin.readline().split()))
- def partition(A, l, r):
- x = choice(A)
- i = l
- j = r
- while (true):
- while A[i] < x:
- i += 1
- while A[j] > x:
- j -= 1
- if i < j:
- i += 1
- j -= 1
- A[i], A[j] = A[j], A[i]
- else:
- return j
- def quickSort(A, l, r):
- if l < r:
- q = partition(A, l, r)
- quickSort(A, l, q - 1)
- quickSort(A, q + 1, r)
- return A
- b = quickSort(a, 0, len(a) - 1)
- for i in range(len(b)):
- print(b[i], end = ' ')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement