Tham khảo:
program im_14424;
uses crt;
var A:array [1..1000] of integer;
i,j,n,tg:integer;
begin clrscr;
write('Nhap so phan tu n: '); readln(n);
for i:=1 to n do
begin
write('Nhap so thu ',i,': ');
read(A[i]);
end;
for i:=1 to n-1 do
for j:=i+1 to n do
if A[i]>A[j] then
begin
tg:=A[i];
A[i]:=A[j];
A[j]:=tg;
end;
writeln('Day so sap xep theo thu tu tang dan la: ');
for i:=1 to n do
write(A[i]:3);
readln;
end.
Code bằng C++
#include <bits/stdc++.h>
using namespace std;
long long a[1000000],i,j,n;
int main()
{
cin>>n;
for (i=1; i<=n; i++)
cin>>a[i];
for (i=1; i<=n-1; i++)
for (j=i+1; j<=n; j++)
if (a[i]>a[j]) swap(a[i],a[j]);
for (i=1;i<=n; i++)
cout<<a[i]<<" ";
return 0;
}