[表示 : 全て 最新50 1-99 101- 201- 301- 401- 501- 601- 701- 801- 901- 1001- 2chのread.cgiへ]
Update time : 04/11 21:43 / Filesize : 404 KB / Number-of Response : 1002
[このスレッドの書き込みを削除する]
[+板 最近立ったスレ&熱いスレ一覧 : +板 最近立ったスレ/記者別一覧] [類似スレッド一覧]


↑キャッシュ検索、類似スレ動作を修正しました、ご迷惑をお掛けしました

くだすれFORTRAN(超初心者用)



509 名前:デフォルトの名無しさん mailto:sage [2006/06/22(木) 09:08:07 ]
>>507
作ってみた
program rndm
real,dimension(:),allocatable :: x; integer :: i,n,stat
read(*,*) n
allocate(x(n),stat=stat)
if(stat/=0) stop "could not allocate x"
do i=1,n
call random_number(x(i))
enddo
print *,"before sort"; call printx(x)
call srt(x)
print *,"after sort"; call printx(x)
deallocate(x)
contains
subroutine printx(x)
real,dimension(:) :: x; integer :: i
do i=1,size(x); print *,x(i); enddo
end subroutine printx
recursive subroutine srt(x)
integer :: i,iflag; real :: tmp
real,dimension(:) :: x
iflag=0
do i=1,size(x)-1
if(x(i)>x(i+1)) then
iflag=1; tmp=x(i); x(i)=x(i+1); x(i+1)=tmp
endif
enddo
if(iflag/=0) call srt(x)
end subroutine srt
end program rndm







[ 続きを読む ] / [ 携帯版 ]

全部読む 前100 次100 最新50 [ このスレをブックマーク! 携帯に送る ] 2chのread.cgiへ
[+板 最近立ったスレ&熱いスレ一覧 : +板 最近立ったスレ/記者別一覧](;´∀`)<404KB

read.cgi ver5.27 [feat.BBS2 +1.6] / e.0.2 (02/09/03) / eucaly.net products.
担当:undef