all tasks

This commit is contained in:
Ingy döt Net 2013-04-11 01:07:29 -07:00
parent b83f433714
commit 68f8f3e56b
14735 changed files with 178959 additions and 0 deletions

View file

@ -0,0 +1,42 @@
program Combsort_Demo
implicit none
integer, parameter :: num = 20
real :: array(num)
call random_seed
call random_number(array)
write(*,*) "Unsorted array:-"
write(*,*) array
write(*,*)
call combsort(array)
write(*,*) "Sorted array:-"
write(*,*) array
contains
subroutine combsort(a)
real, intent(in out) :: a(:)
real :: temp
integer :: i, gap
logical :: swapped = .true.
gap = size(a)
do while (gap > 1 .or. swapped)
gap = gap / 1.3
if (gap < 1) gap = 1
swapped = .false.
do i = 1, size(a)-gap
if (a(i) > a(i+gap)) then
temp = a(i)
a(i) = a(i+gap)
a(i+gap) = temp;
swapped = .true.
end if
end do
end do
end subroutine combsort
end program Combsort_Demo