產生亂數之副程式(劉老師計程班第七次作業)

看板NTUCE-94作者 ( )時間22年前 (2001/11/22 17:24), 編輯推噓0(000)
留言0則, 0人參與, 最新討論串1/2 (看更多)
subroutine random(n,seed) implicit real (a-h,o-z) pi=3.1416 x=(seed+pi)**5 xint=int(x) xi=x-xint seed=xi n=int(seed*10) return stop end 將以上的程式附在程式的某處 使用時只要call random(n,seed) n即是0~9的整數 第一次使用時最好在call副程式前 先給定一個介於0~1的數當seed 以下是某個call random副程式的例子(取50個亂數) program random_number integer a(50),I seed=0.159 do 10,I=1,50 call random(a(I),seed) 10 continue write(*,*) a stop end subroutine random(n,seed) implicit real (a-h,o-z) pi=3.1416 x=(seed+pi)**5 xint=int(x) xi=x-xint seed=xi n=int(seed*10) return stop end 若有同學不懂 請找我 謝謝 化工系309室 洪仕馨 -- ※ 發信站: 批踢踢實業坊(ptt.csie.ntu.edu.tw) ◆ From: 140.112.22.37
文章代碼(AID): #x_CHQ00 (NTUCE-94)
文章代碼(AID): #x_CHQ00 (NTUCE-94)