Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
|
|
@ -0,0 +1,31 @@
|
|||
program Stooge
|
||||
implicit none
|
||||
|
||||
integer :: i
|
||||
integer :: array(50) = (/ (i, i = 50, 1, -1) /) ! Reverse sorted array
|
||||
|
||||
call Stoogesort(array)
|
||||
write(*,"(10i5)") array
|
||||
|
||||
contains
|
||||
|
||||
recursive subroutine Stoogesort(a)
|
||||
integer, intent(in out) :: a(:)
|
||||
integer :: j, t, temp
|
||||
|
||||
j = size(a)
|
||||
if(a(j) < a(1)) then
|
||||
temp = a(j)
|
||||
a(j) = a(1)
|
||||
a(1) = temp
|
||||
end if
|
||||
|
||||
if(j > 2) then
|
||||
t = j / 3
|
||||
call Stoogesort(a(1:j-t))
|
||||
call Stoogesort(a(1+t:j))
|
||||
call Stoogesort(a(1:j-t))
|
||||
end if
|
||||
|
||||
end subroutine
|
||||
end program
|
||||
Loading…
Add table
Add a link
Reference in a new issue