I have twodimensional array that contains random numbers from 0 to 50.
Attention to line 25. At the moment it prints out the highest number out of the random array. How can i print out the smallest?
Code:
program programname;
uses crt;
var
m: array[1..3, 1..3] of integer;
s2k,k, r, l, i, j: integer;
begin
clrscr;
randomize;
for i:=1 to 3 do for j:=1 to 3 do m[i,j]:=random(51);
writeln ('Elements:');
for i:=1 to 3 do
begin
for j:=1 to 3 do write(m[i,j]:3);
writeln;
end;
for i:=1 to 3 do
for j:=1 to 3 do
begin
if l < m[i,j] then
begin
l:= m[i][j];
r:= i;
k:= j;
end;
end;
writeln ('Smallest number is ',l,' and its on ',r, ' row and ',k,' column);
s2k:=0;
for i:=1 to 3 do s2k:=s2k + m[3,i];
writeln ('3. line sum: ', s2k);
readln;
end.