- 512 名前:509,511 mailto:sage [2006/06/23(金) 09:49:52 ]
- 行内複数命令を使わずに出来るだけ短くしてみた
program rndm real,dimension(:),allocatable :: x read(*,*) n allocate(x(n)) call random_number(x) print *,"before sort" print *,x call srt(x) print *,"after sort" print *,x deallocate(x) contains recursive subroutine srt(x) real,dimension(:) :: x iflag=0 do i=1,size(x)-1 if(x(i)>x(i+1)) then iflag=1 x(i:i+1)=(/x(i+1),x(i)/) endif enddo if(iflag/=0) call srt(x) end subroutine srt end program rndm
|

|