
{
PROGRAMMED BY   : MOHAMMAD ALJADA
DOWNLOADED FROM : WWW.GEOCITIES.COM/MOHJADA
PROGRAM         : Sum Arrays Columns and Rows
}

uses wincrt;
type arr=array[1..50,1..50] of integer;

var a:arr;
    n,m,i,j:integer;

procedure read;
begin
write('Input Number Of Rows    : ');
readln(n);
write('Input Number Of Columns : ');
readln(m);
if m>50 then m:=50;
if n>50 then m:=50;
randomize;
for i:=1 to n do
for j:=1 to m do
a[i,j]:=random(101);
end;

procedure show;
var k:integer;
begin;
k:=0;
for i:=1 to n do
begin 
    for j:=1 to m do
    begin
    gotoxy(i*5,j);
    write(a[i,j]);
    k:=k+a[j,i];
    end;
writeln;
end;
writeln;
writeln;
writeln('The Sume Of All Items Is : ',k);
end;

procedure columns;
var k:integer;
begin
for i:=1 to n do
begin
k:=0;
for j:=1 to m do
k:=k+a[i,j];
gotoxy(i*5,m+2);
write(k);
end;
end;


procedure rows;
var k:integer;
begin
for j:=1 to m do
begin
k:=0;
for i:=1 to n do
k:=k+a[i,j];
gotoxy(n*5+5,j);
write(k);
end;
end;


procedure max;
var k,ii,jj,max:integer;
begin
ii:=1;
jj:=1;
max:=a[1,1];
for j:=1 to m do
for i:=1 to n do
if a[i,j]>max then
begin
max:=a[i,j];
ii:=i;
jj:=j;
end;
gotoxy(ii*5,jj);
write('*',a[ii,jj],'*');

end;


BEGIN
read;
clrscr;
show;
columns;
rows;
max;

END.




