SHARE
TWEET

BubbleSort

michalkowalczyk Dec 3rd, 2018 88 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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)
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top