program main
implicit none
integer :: A(5,3), B(3), C(3)
A( 1, : ) = [ 5, 4, 8 ]
A( 2, : ) = [ 4, 1, 9 ]
A( 3, : ) = [ 3, 4, 8 ]
A( 4, : ) = [ 1, 2, 8 ]
A( 5, : ) = [ 3, 1, 0 ]
B = [ 1, 3, 4 ]
C = A(B)
Write(6,*)A
Write(6,*)B
Write(6,*)C
end
program main
implicit none
integer :: A(15), B(3), C(3)
A = [5, 4, 8, 4, 1, 9, 3, 4, 8, 1, 2, 8, 3, 1, 0]
B = [ 1, 3, 4 ]
C = A(B)
Write(6,*)A
Write(6,*)B
Write(6,*)C
end
program main
implicit none
integer :: A(5,3), B(3),D(3), C(3) , j
A( 1, : ) = [ 5, 4, 8 ]
A( 2, : ) = [ 4, 1, 9 ]
A( 3, : ) = [ 3, 4, 8 ]
A( 4, : ) = [ 1, 2, 8 ]
A( 5, : ) = [ 3, 1, 0 ]
B = [ 1, 3, 4 ]
D = [ 1, 2, 3 ]
Do j = 1 , size(B)
C(j) = A(B(j),D(j))
End Do
Write(6,*)C
end
QQ截图20221201175804.png (189.32 KB, 下载次数: 199)
fcode 发表于 2022-12-1 17:19
只能一维数组这样。
多维(N维)数组因为每取一个数,需要N个数做为下标
li913 发表于 2022-12-1 18:00
https://www.bilibili.com/video/BV1XD4y1S7jz?p=3 这里有介绍。
欢迎光临 Fortran Coder (http://bbs.fcode.cn/) | Powered by Discuz! X3.2 |