Var
a:array[1..10,1..20] of integer;
n,m,k,i,j:integer;
begin
write('n = '); readln(n);
write('m = '); readln(m);
for i:=1 to n do
for j:=1 to m do
begin
write('a[',i,',',j,'] = ');
readln(a[i,j]);
end;
writeln('Исходный массив:');
for i:=1 to n do
begin
for j:=1 to m do write(a[i,j]:4,' ');
writeln;
end;
for i:=1 to (n+1) div 2 do
for j:=1 to m div 2 do
begin k:=a[2*i-1,j]; a[2*i-1,j]:=a[2*i-1,m-j+1]; a[2*i-1,m-j+1]:=k; end;
writeln('Измененный массив:');
for i:=1 to n do
begin
for j:=1 to m do write(a[i,j]:4,' ');
writeln;
end;
end.
Пример:
n = 3
m = 4
a[1,1] = 2
a[1,2] = -4
a[1,3] = 0
a[1,4] = 7
a[2,1] = 6
a[2,2] = 9
a[2,3] = -4
a[2,4] = -9
a[3,1] = -4
a[3,2] = 0
a[3,3] = -7
a[3,4] = 0
Исходный массив:
2 -4 0 7
6 9 -4 -9
-4 0 -7 0
Измененный массив:
7 0 -4 2
6 9 -4 -9
0 -7 0 -4