Advertisement
Guest User

Untitled

a guest
Sep 1st, 2018
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.         program zadatak_2
  2.         real:: suma_x = 0, suma_y = 0
  3.         !prethodno moze da se napise i kao real suma_x,suma_y
  4.         !suma_x = 0
  5.         !suma_y = 0
  6.         dimension a(100,100)
  7.         print *, "Uneti dimenzije matrice: "
  8.         read *,n
  9.         print *, "Uneti elemente matrice:"
  10.         read(*,*) ((a(i,j),j=1,n),i=1,n)
  11.         res = result(a,n)
  12.         print *, res
  13.         end
  14.  
  15.  
  16.         function result(a,n)
  17.          dimension a(100,100)
  18.          suma_x = 0
  19.          suma_y = 0
  20.          do i=1,n
  21.            do j=1,n
  22.               !prvi red - X
  23.               if((i .eq. 1) .and. (j .ne. n) .and. (j .ne.1)) then
  24.                      suma_x = suma_x + a(i,j)
  25.               endif
  26.                !poslenja kolona - X
  27.               if((j .eq. n) .and. (i .ne. n) .and. (i .ne.1)) then
  28.                      suma_x = suma_x + a(i,j)
  29.               endif
  30.                !poslednji red - Y
  31.                if((i .eq. n) .and. (j .ne. n) .and. (j .ne.1)) then
  32.                      suma_y = suma_y + a(i,j)
  33.               endif
  34.                !prva kolona - Y
  35.               if((j .eq. 1) .and. (i .ne. n) .and. (i .ne.1)) then
  36.                      suma_y = suma_y + a(i,j)
  37.               endif
  38.  
  39.            end do
  40.         end do
  41.         result = 0
  42.         if (suma_x .gt. suma_y) then
  43.            result = 1
  44.  
  45.         else if(suma_x .lt. suma_y) then
  46.            result = -1
  47.         endif
  48.         !print *, suma_x
  49.         !print *, suma_y
  50.         return
  51.         end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement