Const n=10; var a:array[1..n] of integer; i,t:integer; begin Randomize; writeln('A:'); for i:=1 to n do begin a[i]:=random(21)-10; write(a[i]:4); end; writeln; for i:=1 to n div 4 do begin t:=a[i]; a[i]:=a[n div 2-i+1]; a[n div 2-i+1]:=t; t:=a[n div 2+i]; a[n div 2+i]:=a[n-i+1]; a[n-i+1]:=t; end; writeln('new A:'); for i:=1 to n do write(a[i]:4); writeln; end.
var a:array[1..n] of integer;
i,t:integer;
begin
Randomize;
writeln('A:');
for i:=1 to n do
begin
a[i]:=random(21)-10;
write(a[i]:4);
end;
writeln;
for i:=1 to n div 4 do
begin t:=a[i]; a[i]:=a[n div 2-i+1]; a[n div 2-i+1]:=t;
t:=a[n div 2+i]; a[n div 2+i]:=a[n-i+1]; a[n-i+1]:=t; end;
writeln('new A:');
for i:=1 to n do write(a[i]:4);
writeln;
end.
Пример:
A:
-8 -10 -7 4 -6 10 7 10 -7 1
new A:
-6 4 -7 -10 -8 1 -7 10 7 10