239
>Afiseaza elementele de pe diagonala principala, secundara, de deasupra si de dedesuptul celor 2 diagonale.
program diagonale;
var a:array[1..50,1..50] of integer;
n,i,j:integer;
begin
write('n=');readln(n);
for i:=1 to n do
for j:=1 to n do begin
write('a[',i,',',j,']=');readln(a[i,j]);
end;
for i:=1 to n do begin
for j:=1 to n do write(a[i,j], ' ');
writeln;
end;
writeln('elem de deasupra diag prin:');
for i:=1 to n-1 do begin
for j:=i+1 to n do write(a[i,j], ' ');
end;
writeln;
writeln('elem de sud diag princ:');
for i:= 2 to n do begin
for j:=1 to i-1 do write(a[i,j], ' ');
end;
writeln;
writeln('elem de diag princ:');
for i:=1 to n do
for j:= 1to n do begin
if i=j then write(a[i,j], ' ');
end;
writeln;
writeln('elem de sub diag sec');
for i:= 1 to n do
for j:= 1 to n do begin
if i+j>n+1 then write(a[i,j], ' ');
end;
writeln;
writeln('elem de peasupra diag sec');
for i:= 1 to n do
for j:= 1 to n do begin
if i+j<n+1 then write(a[i,j], ' ');
end;
writeln;
writeln('elem de pe diag sec');
for i:= 1 to n do
for j:= 1 to n do begin
if i+j=n+1 then write(a[i,j], ' ');
end;
writeln;
readln;
end.
{by Popescu Ionel PascalZone.evonet.ro}