Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def swap(a,i,j):
- b=a[i]
- a[i]=a[j]
- a[j]=b
- def bubblesort(A):
- n=len(A)-1
- for i in range(n-1):
- for j in range(n-i):
- if A[j]>A[j+1]:
- swap(A,j,j+1)
- from random import*
- a=20*[0]
- for i in range(20):
- a[i]=randint(1,1000)
- b=5*[0]
- c=5*[0]
- d=5*[0]
- e=5*[0]
- for i in range(4):
- if i==0:
- b=a[:5]
- if i==1:
- c=a[5:10]
- if i==2:
- d=a[10:15]
- else:
- e=a[15:]
- bubblesort(b)
- bubblesort(c)
- bubblesort(d)
- bubblesort(e)
- a=b+c+d+e
- print(a)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement