ovo sam uradio nabrzinu. ni meni se ne sviđa onaj uslov kako prepoznaje članove dijagonala, ali nisam imao vremena da tražim nešto jednostavnije!
Code:
program matrica;
{
by del-boy
}
uses crt;
var i,j,n,x,z:integer;
a:array[1..100,1..100] of integer;
d:array[1..100] of integer;
begin
clrscr;
repeat
begin
write('n=');
readln(n);
if (n<=0) then writeln('GRESKA! Unesite n ponovo...');
end;
until (n>0);
for i:=1 to n do
for j:=1 to n do
begin
write('a[',i,',',j,']=');
readln(a[i,j]);
end;
x:=0;
while x<=n do
begin
x:=x+1;
d[x]:=0;
z:=0;
for i:=1 to n do
begin
for j:=1 to n do
begin
if ((2*n-z)-2*(n-i)=x+j) then d[x]:=d[x]+a[i,j];
end;
z:=z+1;
end;
end;
writeln;
for i:=1 to n do
begin
for j:=1 to n do
write(a[i,j]);
writeln;
end;
writeln;
for i:=1 to n do writeln(d[i]);
end.