2 câu trả lời
program sap_xep_tang_dan;
uses crt;
var a:array [1..100] of longint;
var n, d, i, j, t, k: longint;
begin
clrscr;
write ('nhap so phan tu cua day so: '); readln (n);
writeln ('nhap day so: ');
for i:=1 to n do
begin
write ('a[',i,']='); readln (a[i]);
end;
for i:=1 to n-1 do
for j:=i+1 to n do
if a[i]>a[j] then
begin
t:=a[i];
a[i]:=a[j];
a[j]:=t;
end;
write ('day so sau khi sap xep: ');
for i:=1 to n do
write (a[i],' ');
readln;
end.
program sapxep;
uses crt;
var A:array[1..100] of integer;
n,i,j:byte;
tam:integer;
begin
clrscr;
write('Nhap so luong phan tu cua mang: '); readln(n);
writeln('Nhap tung phan tu cua day: ');
for i:=1 to n do
begin
write('Nhap phan tu thu ',i,': ');
readln(A[i]);
end;
for i:=1 to n-1 do
for j:=i+1 to n do
if A[i]>A[j] then
begin
tam:=A[i];
A[i]:=A[j];
A[j]:=tam;
end;
write('Day sau khi sap xep la: ');
for i:=1 to n do
write(A[i],' ');
readln
end.