subroutine findext(a,n,max,min)
implicit none
integer i,n
real*8 a(n),max,min
max=a(1)
min=a(1)
do i=2,n
if(a(i)>max) then
max=a(i)
else
min=a(i)
endif
enddo
end subroutine findext
例子,矩阵real*8 m(n,n)
real*8 temp(n)
第n行的最大最小值
temp=m(n,:)
call findext(temp,n, max,min)
第n列的最大最小值
temp=m(:,n)
call findext(temp,n, max,min)
对角线
do i=1,n
temp(i)=m(i,i)
enddo
call findext(temp,n, max,min)
已发送,查收