Advertisement
Guest User

Untitled

a guest
Jan 7th, 2017
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. program random_matrix
  2. implicit none
  3.  
  4.  
  5. real, allocatable:: A(:,:)          ! matrix for which the determinant is calculated
  6. integer             n               ! size of the matrix A nxn
  7. integer             i,j             ! loop indexes
  8. real                r               ! random number
  9.  
  10. ! Typing in the size of the matrix and amount of 0
  11. !**************************************************************************!
  12. write(*,*)  'amount of rows and colums'
  13. read(*,*)   n
  14. allocate (A(n,n))
  15.  
  16. ! Creating the matrix of random numbers
  17. !**************************************************************************!
  18.  
  19. do i=1,n
  20.     do j=1,n
  21.         r=rand()
  22.     A(i,j)=floor((r*10.0)+1)
  23.     enddo
  24. enddo  
  25. call print_matrix
  26.    
  27.  
  28.  
  29. end program
  30.            
  31. subroutine print_matrix
  32.     implicit none
  33.     integer                             n               ! size of the matrix A nxn
  34.     real, allocatable::                 A(:,:)
  35.     integer ::                          i,j
  36.  
  37.      do i = 1, n
  38.            write (*,10) (A(i,j), j = 1, n)
  39.      10 format (6i3)
  40.      end do
  41.    
  42.  
  43. end subroutine
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement