Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- program zadatak_2
- real:: suma_x = 0, suma_y = 0
- !prethodno moze da se napise i kao real suma_x,suma_y
- !suma_x = 0
- !suma_y = 0
- dimension a(100,100)
- print *, "Uneti dimenzije matrice: "
- read *,n
- print *, "Uneti elemente matrice:"
- read(*,*) ((a(i,j),j=1,n),i=1,n)
- res = result(a,n)
- print *, res
- end
- function result(a,n)
- dimension a(100,100)
- suma_x = 0
- suma_y = 0
- do i=1,n
- do j=1,n
- !prvi red - X
- if((i .eq. 1) .and. (j .ne. n) .and. (j .ne.1)) then
- suma_x = suma_x + a(i,j)
- endif
- !poslenja kolona - X
- if((j .eq. n) .and. (i .ne. n) .and. (i .ne.1)) then
- suma_x = suma_x + a(i,j)
- endif
- !poslednji red - Y
- if((i .eq. n) .and. (j .ne. n) .and. (j .ne.1)) then
- suma_y = suma_y + a(i,j)
- endif
- !prva kolona - Y
- if((j .eq. 1) .and. (i .ne. n) .and. (i .ne.1)) then
- suma_y = suma_y + a(i,j)
- endif
- end do
- end do
- result = 0
- if (suma_x .gt. suma_y) then
- result = 1
- else if(suma_x .lt. suma_y) then
- result = -1
- endif
- !print *, suma_x
- !print *, suma_y
- return
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement