Add tasks for all the new languages
This commit is contained in:
parent
9dc3c2bb62
commit
bba7bfd280
13208 changed files with 134745 additions and 0 deletions
20
Task/Quickselect-algorithm/Ring/quickselect-algorithm.ring
Normal file
20
Task/Quickselect-algorithm/Ring/quickselect-algorithm.ring
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
aList = [9, 8, 7, 6, 5, 0, 1, 2, 3, 4]
|
||||
see partition(aList, 9, 4, 2) + nl
|
||||
|
||||
func partition list, left, right, pivotIndex
|
||||
pivotValue = list[pivotIndex]
|
||||
temp = list[pivotIndex]
|
||||
list[pivotIndex] = list[right]
|
||||
list[right] = temp
|
||||
storeIndex = left
|
||||
for i = left to right-1
|
||||
if list[i] < pivotValue
|
||||
temp = list[storeIndex]
|
||||
list[storeIndex] = list[i]
|
||||
list[i] = temp
|
||||
storeIndex++ ok
|
||||
temp = list[right]
|
||||
list[right] = list[storeIndex]
|
||||
list[storeIndex] = temp
|
||||
next
|
||||
return storeIndex
|
||||
Loading…
Add table
Add a link
Reference in a new issue