Sum of elements below main diagonal of matrix

Revision as of 06:21, 20 July 2021 by CalmoSoft (talk | contribs) (Created page with "{{Draft task}} ;Task:Find sum of elements below main diagonal of matrix. <br>The matrix should be square matrix. <br><br>Matrix = [[1,3,7,8,10], [2,4,16,14,...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)


The matrix should be square matrix.

Matrix = [[1,3,7,8,10],

Sum of elements below main diagonal of matrix is a draft programming task. It is not yet considered ready to be promoted as a complete task, for reasons that should be found in its talk page.
Task
Find sum of elements below main diagonal of matrix.
                 [2,4,16,14,4],
                 [3,1,9,18,11],
                 [12,14,17,18,20],
                 [7,1,3,9,5]]



Ring

<lang ring> see "working..." + nl see "Sum of elements below main diagonal of matrix:" + nl diag = [[1,3,7,8,10],

       [2,4,16,14,4],
       [3,1,9,18,11],
       [12,14,17,18,20],
       [7,1,3,9,5]]

lenDiag = len(diag) ind = lenDiag sumDiag = 0

for n=1 to lenDiag

   for m=1 to lenDiag-ind
       sumDiag += diag[n][m]
   next
   ind--

next

see "" + sumDiag + nl see "done..." + nl </lang>

Output:
working...
Sum of elements below main diagonal of matrix:
69
done...