/*Sap xep mang theo thu Tu Tang Dan*/
#include<stdio.h>
#include<conio.h>
void Xuat(int a[50],int n)
{
int i;
printf("Mang la: ");
for (i=0;i<n;i++)
printf("%5d",a[i]);
}
void sapxep(int a[50],int n) //sap xep cac so trong mang
{
int i,j;
for (i=0; i for (j=i+1; j {
if (a[i]>a[j])
{
int tg=a[i];
a[i]=a[j];
a[j]=tg;
}
}
printf("\nMang sau khi sap xep la: ");
for (j=0;j {
printf("%5d",a[j]);
}
}
main()
{
lap:
clrscr();
int a[50];
int n,k,x,m,j,d;
printf("Nhap so phan tu: ");
scanf("%d",&n);
for (int i=0;i {
printf("a[%d]",i);
scanf("%d",&a[i]);
}
Xuat(a,n);
sapxep(a,n);
printf("\n\n=================\nCopyRight Le van Toan\n\nLaSinhVien.Vn - Gan Ket Tuoi Tre Chia Se THanh Cong!");
getch();
goto lap;
}