看板 Fortran 關於我們 聯絡資訊
x= 123 y= 456 call swap_int(x, y) ! 把兩個變數 x, y 的值作 交換的動作 a= 123.45 b= 124.56 if (rel_diff(a, b) .LT. 1.0e-5) then ! 符合相對誤差的要求,跳出這個 迴圈 goto 100 end if . . . 100 continue ! swap_int() 是 subroutine ! rel_diff() 是 function ※ 引述《shelling (shelling)》之銘言: : 新手上路 : 請教一下 subroutine 和 function 這兩個宣告方式有什麼不同呢? -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 118.231.149.204
blc:簡單地說,function會傳值回來,subroutine不會。 10/07 20:08
shelling:大感謝 :D 10/11 00:53