?? ex0817.f90
字號:
program ex0817
implicit none
integer, parameter :: size = 5
integer :: s = size
integer :: a(size) = (/ 1,2,3,4,5 /)
call UseArray1(a,size) ! 把常數size傳入做數組大小
call UseArray1(a,s) ! 把一般變數s 傳入做數組大小
call UseArray2(a) ! 不傳入數組大小
call UseArray3(a)
stop
end
subroutine UseArray1(num, size)
implicit none
integer :: size
integer :: num(size) ! 傳入的數組大小可用變量來指定
write(*,*) num
return
end
subroutine UseArray2(num)
implicit none
integer :: num(*) ! 不指定數組大小
integer :: i
write(*,*) (num(i), i=1,5)
! 如果傳入的數組大小少于5, write在執行時會出現錯誤
return
end
subroutine UseArray3(num)
implicit none
integer :: num(-2:2) ! 可以重新定義數組坐標范圍
write(*,*) num(0)
return
end
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -