[Fortran] 纯文本查看 复制代码
Program Test
Implicit None
Integer, Parameter :: M = 6, N = 5
Integer G(N, M), W(N, N), I, J, K
G = reshape( (/ -1, 0, 0, 0, 0,&
1, -1, 0, 0, 0,&
0, 1, -1, 0, 0,&
0, 0, 1, -1, -1,&
0, 0, 0, 1, 0,&
0, 0, 0, 0, 1/), (/n,m/) )
W = 0
Do I = 1, N
Do J = 1, M
If (G(I,J)==1) Then
Do K = 1, N
If (G(K,J)==-1) W(K, I) = 1
End Do
Exit
End If
End Do
End Do
Write (*, '(5i4)') W
! 0 1 0 0 0
! 0 0 1 0 0
! 0 0 0 1 1
! 0 0 0 0 0
! 0 0 0 0 0
End Program Test