fork(1) download
  1. PARAMETER(N=3)
  2. DIMENSION A(N,N)
  3. READ*,((A(I,J),J=1,N),I=1,N)
  4. SUMU=0.0
  5. SUML=0.0
  6. SUMD=0.0
  7. DO 7 I=1,N
  8. DO 10 J=1,N
  9. IF(I.LT.J)SUMU=SUMU+A(I,J)
  10. IF(I.GT.J)SUML=SUML+ A(I,J)
  11. IF(I.EQ.J)SUMD=SUMD+ A(I,J)
  12. 10 CONTINUE
  13. 7 CONTINUE
  14. PRINT*,'Sum of elements above main diagonal=',SUMU
  15. PRINT*,'Sum of elements below main diagonal=',SUML
  16. PRINT*,'Sum of elements in the main diagonal=',SUMD
  17. STOP
  18. END
Success #stdin #stdout 0.01s 5284KB
stdin
1 5 3 
2 6 4 
2 4 5 
stdout
 Sum of elements above main diagonal=   12.0000000    
 Sum of elements below main diagonal=   8.00000000    
 Sum of elements in the main diagonal=   12.0000000