Last active
December 5, 2017 22:32
-
-
Save zrhans/7a57ee75799e87246cc3e7883fb647ee to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
! Atividade:https://my.pcloud.com/publink/show?code=XZn8R57ZwL98CRSObpY6l3Bb75cirVU9Ky5k | |
! | |
program work_3 | |
implicit none ! Adicionado por Hans | |
integer :: nc, nl, i, j | |
real,dimension(:,:), allocatable :: matriz | |
real,dimension(:), allocatable :: maxval1(:) | |
logical :: exis_arq | |
inquire(file='MATRIZ.DAT', exist=exis_arq) | |
if (exis_arq) then | |
open(unit=1,file='MATRIZ.DAT') | |
read(unit=1,fmt=*) nl, nc | |
allocate(matriz(nl,nc)) | |
allocate(maxval1(nc)) | |
do i = 1,nl | |
read(1,fmt=*) matriz(i,:) | |
end do | |
close(unit=1) | |
call maximo_colunas(nl,nc,matriz,maxval1) | |
print *, 'VALORES MAXIMOS:' | |
print *, 'COLUNA | VALORE MAXIMO' | |
do i = 1, nc | |
write(*,*) i,maxval1(i) | |
end do | |
else | |
print *, 'O arquivo MATRIZ.DAT não pode ser aberto' | |
end if | |
contains | |
subroutine maximo_colunas(m,n,a, maximos) | |
integer, intent(in) :: m, n | |
real, dimension(m,n), intent(in) :: A | |
real, dimension(n), intent(out) :: maximos | |
integer :: k | |
do k = 1,n | |
maximos(k) = MAXVAL(A(:,k)) | |
end do | |
end subroutine maximo_colunas | |
end program work_3 | |
! conteudo do arquivos de dados | |
! MATRIZ.DAT | |
! https://my.pcloud.com/publink/show?code=XZluU57ZbtFi8vfIh4hBpnEg2315qzuktr47 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment