36 25 24 13 12 1
35 26 23 14 11 2
34 27 22 15 10 3
33 28 21 16 9 4
32 29 20 17 8 5
31 30 19 18 7 6
Объяснение:
1)
const n=6;
var a:array[1..n,1..n] of integer;
i,j:integer;
begin
for i:=1 to n do
if i mod 2=1
then for j:=1 to n do a[i,j]:=n*i-j+1
else for j:=1 to n do a[i,j]:=n*(i-1)+j;
for j:=1 to n do write(a[i,j]:3);
writeln;
end;
end.
Результат:
6 5 4 3 2 1
7 8 9 10 11 12
18 17 16 15 14 13
19 20 21 22 23 24
30 29 28 27 26 25
31 32 33 34 35 36
2)
for j:=n downto 1 do
if (n+j) mod 2=0
then for i:=1 to n do a[i,j]:=n*(n-j)+i
else for i:=1 to n do a[i,j]:=n*(n-j+1)-i+1;
36 25 24 13 12 1
35 26 23 14 11 2
34 27 22 15 10 3
33 28 21 16 9 4
32 29 20 17 8 5
31 30 19 18 7 6
Объяснение:
1)
const n=6;
var a:array[1..n,1..n] of integer;
i,j:integer;
begin
for i:=1 to n do
if i mod 2=1
then for j:=1 to n do a[i,j]:=n*i-j+1
else for j:=1 to n do a[i,j]:=n*(i-1)+j;
for i:=1 to n do
begin
for j:=1 to n do write(a[i,j]:3);
writeln;
end;
end.
Результат:
6 5 4 3 2 1
7 8 9 10 11 12
18 17 16 15 14 13
19 20 21 22 23 24
30 29 28 27 26 25
31 32 33 34 35 36
2)
const n=6;
var a:array[1..n,1..n] of integer;
i,j:integer;
begin
for j:=n downto 1 do
if (n+j) mod 2=0
then for i:=1 to n do a[i,j]:=n*(n-j)+i
else for i:=1 to n do a[i,j]:=n*(n-j+1)-i+1;
for i:=1 to n do
begin
for j:=1 to n do write(a[i,j]:3);
writeln;
end;
end.
Результат:
36 25 24 13 12 1
35 26 23 14 11 2
34 27 22 15 10 3
33 28 21 16 9 4
32 29 20 17 8 5
31 30 19 18 7 6