二维数组鞍点问题

Program AnDian  !鞍点问题
    implicit none
    real,allocatable::a(:,:)
    integer r,c,i,j
    integer flag,flagc
    real maxr,minr
    write(*,*) "Input matrix`s row and col:"
    read(*,*) r,c
    allocate(a(r,c))
    call random_seed()
    do i=1,r
        do j=1,c
            call random_number(a(i,j))
            a(i,j)=a(i,j)*100
        enddo
    enddo
    do i=1,r
        do j=1,c-1
            write(*,10,advance='no') a(i,j)
10          format((F8.3,1X))
        enddo
        write(*,*) a(i,c)
    enddo
    
    
    do i=1,r
        maxr=a(i,1)
        flag=1
        flagc=1
        do j=2,c
            if(a(i,j).gt.maxr) then
                maxr=a(i,j)
                flagc=j
            endif
        enddo
        do j=1,r
            if(a(j,flagc).lt.a(i,flagc)) then
                flag=-1
            endif
        enddo
        if(flag.eq.1) then
            write(*,*) "a(",i,",",flagc,")是鞍点"
        endif
    enddo
    deallocate(a)
    stop
    end

你可能感兴趣的:(二维数组鞍点问题)