Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and medical aesthetics - It is known that A(5,5) is an integer array, program to find the largest element and its position on the two diagonals. (written in fortran90)
It is known that A(5,5) is an integer array, program to find the largest element and its position on the two diagonals. (written in fortran90)

Generally, I don’t recommend asking people on Baidu all your questions.

Okay, I will answer half of this question for you. I hope you will write another diagonal line and the code for the double loop yourself.

Program Main

Implicit None

Integer , parameter :: N = 5

Integer :: A(N,N) = (/5,4,3,2,1,7,8,5,4,3,4,5,6,8,3,5,6,8,3,2,4,6,8,3, 2/)

Integer :: iMax , iMaxLoc , iMin , iMinLoc , i , j

iMax = A(1,1)

iMin = A( 1,1)

iMaxLoc = 1

iMinLoc = 1

Do i = 1 , N

if ( A(i, i) > iMax ) then

iMax = A(i,i)

iMaxLoc = i

end if

if ( A (i,i) < iMin ) then

iMin = A(i,i)

iMinLoc = i

end if

End Do

write( * , * ) iMax , iMaxLoc , iMin , iMinLoc

End Program Main