Advertisement
michalkowalczyk

BubbleSort

Dec 3rd, 2018
130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.42 KB | None | 0 0
  1. # -*- coding: utf-8 -*-
  2. """
  3. Created on Mon Nov 19 07:59:01 2018
  4.  
  5. @author: kowamich
  6. """
  7.  
  8. A=[]
  9. from random import randint
  10. for i in range(0,100):
  11.     j=randint(1,100)
  12.     A.append(j)
  13. print(A)    
  14.  
  15. def sort(A):
  16.     for i in range(len(A) - 1, 0, -1):
  17.         for j in range(i):
  18.             if A[j] > A[j + 1]:
  19.                 z=A[j+1]
  20.                 A[j+1]=A[j]
  21.                 A[j]=z
  22.          
  23.  
  24. sort(A)
  25. print(A)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement