var i, j: integer; a: array[1..n, 1..n] of integer;
begin for i := 1 to n do for j := 1 to n do if i = j then a[i, i] := n - i + 1 else a[i, j] := 0; writeln; for i := 1 to n do begin for j := 1 to n do write(a[i, j]:4); writeln end end.
Const n = 10; var matrix : array [1..n] of array [1..n] of integer; i, j, max : integer; begin {формирование матрицы} for j := 1 to n do begin if j <= Trunc(n / 2) then {находим последний индекс для вставки 1} max := j else max := n - j + 1; for i := 1 to max do {заполняем линию единицами} begin matrix[j][i] := 1; matrix[j][n - i + 1] := 1; end; end; {вывод матрицы (если не нужно, удалите код)} for j := 1 to n do begin for i := 1 to n do write(matrix[j][i], ' '); writeln; end; end.
n = 10;
var
i, j: integer;
a: array[1..n, 1..n] of integer;
begin
for i := 1 to n do
for j := 1 to n do
if i = j then a[i, i] := n - i + 1
else a[i, j] := 0;
writeln;
for i := 1 to n do
begin
for j := 1 to n do write(a[i, j]:4);
writeln
end
end.
10 0 0 0 0 0 0 0 0 0
0 9 0 0 0 0 0 0 0 0
0 0 8 0 0 0 0 0 0 0
0 0 0 7 0 0 0 0 0 0
0 0 0 0 6 0 0 0 0 0
0 0 0 0 0 5 0 0 0 0
0 0 0 0 0 0 4 0 0 0
0 0 0 0 0 0 0 3 0 0
0 0 0 0 0 0 0 0 2 0
0 0 0 0 0 0 0 0 0 1
n = 10;
var
matrix : array [1..n] of array [1..n] of integer;
i, j, max : integer;
begin
{формирование матрицы}
for j := 1 to n do
begin
if j <= Trunc(n / 2) then {находим последний индекс для вставки 1}
max := j
else
max := n - j + 1;
for i := 1 to max do {заполняем линию единицами}
begin
matrix[j][i] := 1;
matrix[j][n - i + 1] := 1;
end;
end;
{вывод матрицы (если не нужно, удалите код)}
for j := 1 to n do
begin
for i := 1 to n do
write(matrix[j][i], ' ');
writeln;
end;
end.