Program hotrotinhoc;
var a: array[1..32000] of integer;
i,n,j,tg,k,t: integer;
begin
write('n='); readln(n);
for i:=1 to n do
begin
write('a[',i,']='); readln(a[i]);
end;
write('k='); readln(k);
for i:=1 to n do
for j:=i to n do
if a[i]>a[j] then
begin
tg:=a[i];
a[i]:=a[j];
a[j]:=tg;
end;
writeln('Day sap xep theo thu tu tang dan la :');
for i:=1 to n do
begin
write(a[i],' ');
if a[i]<k then t:=i;
end;
writeln('Day sau khi chen k : ');
for i:=1 to n do
if (a[i]<k) and (t=i) then write(a[i],' ',k,' ') else write(a[i],' ');
readln
end.
uses crt;
var a:array[1..100]of integer;
k,n,i,tam,x,t:integer;
begin
clrscr;
write('nhap so phan tu:'); readln(n);
for i:=1 to n do
begin
write('a[',i,']='); readln(a[i]);
end;
{-----------------------------------------------------}
for i:=1 to n do write(a[i],' ');
{----------------------------------------------------------------}
writeln;
writeln('day tang dan la:');
for i:=1 to n-1 do
for k:=i+1 to n do
if a[i]>a[k] then begin
t:=a[i];
a[i]:=a[k];
a[k]:=t;
end;
for i:=1 to n do write(a[i],' ');
writeln;
{--------------------------------------------}
write('nhap gia tri x:'); readln(x);
i:=1;
while(x>a[i]) and (i<=n) do
i:=i+1;
for k:=n+1 downto i do
a[k]:=a[k-1];
a[i]:=x;
writeln('mang da chen x:');
for i:=1 to n+1 do write(a[i],' ');
readln;
end.