Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
HW selectionsort using while
#python 3.5.2 #print ("Hello, world!") def SelectionSort(y): length=len(y) nlastposition=length-1 numindex=0 while nlastposition >=0: numbindex =0 while numbindex < nlastposition+1: maxindex=0 if y[numindex] > y[maxindex]: maxindex = numindex numbindex=numbindex+1 print ("Max number: ", y[maxindex]) temp = y[nlastposition] y[nlastposition] = y[maxindex] y[maxindex] = temp print ("After swap: ", y) print () nlastposition=nlastposition-1 return y s = [26,54,93,17,77,31] sortList = SelectionSort(s) print (sortList)
run
|
edit
|
history
|
help
0
Два шарика в квадрате
31 dec
raja praja
shuru2
count(even/odd)fromlist.py
Insert a sequence of same numbers, unpacking
1.py
Hello world
PyQP
Search by starting alphabets.