Ответы и объяснения

2013-03-14T23:34:56+04:00

uses crt;
var a:array [1..100]of integer;
n,i,j,k,x:integer;
begin
clrscr;
randomize;
write('n=');readln(n);
writeln('Ishodnyj massiv:');
for i:=1 to n do
begin
a[i]:=random(200);;
write(a[i],' ');
end;
writeln;
for i:=2 to n do
begin
x:=a[i];
j:=1;
while x>a[j] do inc(j);
for k:=i-1 downto j do a[k+1]:= a[k];
a[j]:=x;
end;
writeln('Otsortirovannyj massiv:');
for i:=1 to n do
write(a[i],' ');
readln
end.