看板 Fortran 關於我們 聯絡資訊
這裡是 輸出,請刪除 1 0 2 -3 3 -2 4 0 5 -1 6 -1 7 -1 8 -2 9 1 10 -9 11 -3 12 -2 13 -3 14 -2 15 1 16 -1 17 -2 18 1 19 0 20 0 21 -1 22 1 23 0 24 -3 25 -3 Press any key to continue ! ----------------------------------------------- program VF1019 implicit none integer a, b, c, i, x(25), n1, n2 integer min, max, tt real*4 y data x/-3, -3, -3, -3, -3, -2, -2, -2, -2, -2, -1, -1, -1, -1, -1, 0, 0, 0, 0, 0, 1, 1, 1, 1, -9/ call random_seed() do i=1, 25*10 call random_number(y) n1= y*25.0 + 1.0 call random_number(y) n2= y*25.0 + 1.0 ! swap x(n1), x(n2) tt= x(n1) x(n1)= x(n2) x(n2)= tt end do do i=1,25 print *, i, x(i) end do end program VF1019 ※ 引述《janewinnie (逃離)》之銘言: : 請問fortran有沒有一個指令是可以將數值隨機排序的? : 例如我原本的資料為 : -3 -3 -3 -3 -3 -2 -2 -2 -2 -2 -1 -1 -1 -1 -1 0 0 0 0 0 1 1 1 1 1 : 我想要它隨機排序變成 : -3 -2 0 -2 1 -1 -3 -3 0 1 -2....... -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 60.245.110.241
charlesdc:跟氣泡法有異曲同工之妙@@ 10/19 19:55