主题:急!求指点qsort如何对实数排序
program main
external compar
integer*2 compar
INTEGER*4:: array(10)=(/5,1,9,0,8,7,3,4,6,2/),len=10,isize=4
call qsort( array, len, isize, compar )
write(*,'(10i3)') array
end
integer*2 function compar( a, b )
INTEGER*4 a, b
if ( a .lt. b ) compar = -1
if ( a .eq. b ) compar = 0
if ( a .gt. b ) compar = 1
return
end
program main
external compar
real*8 compar
real*8:: array(10)=(/5,1,9,0,8,7,3,4,6,2/)
integer:: len=10,isize=8
call qsort( array, len, isize, compar )
write(*,'(10f9.0)') array
end
real*8 function compar( a, b )
real*8 a, b
if ( a .lt. b ) compar = -1
if ( a .eq. b ) compar = 0
if ( a .gt. b ) compar = 1
return
end
external compar
integer*2 compar
INTEGER*4:: array(10)=(/5,1,9,0,8,7,3,4,6,2/),len=10,isize=4
call qsort( array, len, isize, compar )
write(*,'(10i3)') array
end
integer*2 function compar( a, b )
INTEGER*4 a, b
if ( a .lt. b ) compar = -1
if ( a .eq. b ) compar = 0
if ( a .gt. b ) compar = 1
return
end
program main
external compar
real*8 compar
real*8:: array(10)=(/5,1,9,0,8,7,3,4,6,2/)
integer:: len=10,isize=8
call qsort( array, len, isize, compar )
write(*,'(10f9.0)') array
end
real*8 function compar( a, b )
real*8 a, b
if ( a .lt. b ) compar = -1
if ( a .eq. b ) compar = 0
if ( a .gt. b ) compar = 1
return
end