Câu trả lời:
program Mang;
uses crt;
var a:array[1..100] of integer;
x,i,n,j,temp:integer;
begin clrscr;
write('Nhap n = '); readln(n);
for i:=1 to n do
begin
write('a[',i,']= '); readln(a[i]);
end;
for i:=1 to n do
for j:=i+1 to n do
if (a[i] < a[j]) then
begin
temp := a[i];
a[i] := a[j];
a[j] := temp;
end;
for i:=1 to n do
writeln(a[i]);
write('Nhap x = '); readln(x);
a[n+1] := x;
for i:=1 to n+1 do
for j:=i+1 to n+1 do
if (a[i] < a[j]) then
begin
temp := a[i];
a[i] := a[j];
a[j] := temp;
end;
for i:=1 to n+1 do
writeln(a[i]);
readln;
end.