Sum of elements below main diagonal of matrix: Difference between revisions

no edit summary
(added Arturo)
No edit summary
Line 590:
{{out}}
<pre>69</pre>
 
=={{header|Delphi}}==
{{works with|Delphi|6.0}}
{{libheader|SysUtils,StdCtrls}}
 
 
<syntaxhighlight lang="Delphi">
type T5Matrix = array[0..4, 0..4] of Double;
 
var TestMatrix: T5Matrix =
(( 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));
 
 
function BottomTriangleSum(Mat: T5Matrix): double;
var X,Y,X2: integer;
var D: double;
begin
Result:=0;
for Y:=1 to 4 do
for X:=0 to Y-1 do
begin
D:=Mat[Y,X];
Result:=Result+D;
end;
end;
 
 
procedure ShowBottomTriangleSum(Memo: TMemo);
var Sum: double;
begin
Sum:=BottomTriangleSum(TestMatrix);
Memo.Lines.Add(IntToStr(Trunc(Sum)));
end;
 
 
</syntaxhighlight>
{{out}}
<pre>
69
Elapsed Time: 0.873 ms.
 
</pre>
 
 
=={{header|Excel}}==
465

edits