SHARE
TWEET

pr8(file)

starm100 Dec 11th, 2018 87 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. program pr8 ! задание: хотя бы в одной строке матрицы все элементы не превосходят b
  2. integer::i,j,m,n
  3. real::b=10**3
  4. real,dimension(:,:),allocatable::A
  5. print*, 'Input m,n'
  6. read(*,*) m,n
  7. allocate(A(1:m,1:n))
  8. open(101,file='matrix.txt',status='old') ! матрица в файле должна соответствовать m,n
  9. do i=1,m
  10.     read(101,*) A(i,:)
  11.     call check(A,i,b)
  12.     do j=1,n
  13.         write(*,'(f7.2\)') A(i,j)
  14.     end do
  15.     print*, ' '
  16. end do
  17. close(101)
  18. deallocate(A)
  19. write(*,'(/"Ans.-",f7.2)') b  
  20. contains
  21.    
  22.     subroutine check(A,m,b) ! maxval(ARRAY,[DIM=],[MASK=])-returns max value of an array
  23.     integer::i,j,m,n
  24.     real,intent(in)::A(:,:)
  25.     real::b,max
  26.     max=maxval(A(m,:))
  27.     if (b>max) then
  28.         b=max
  29.     end if
  30.     end subroutine
  31.    
  32. end
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top