Code:

void HoanVi(int &a, int &b)
{
   int temp = a;
   a = b;
   b = temp;
}
void BubleSort(int A[], int n)
{
   for(int i = 0; i<n-1; i++)
      for(int j = n-1; j>i; j--)
      if(A[j]<A[j-1])
         HoanVi(A[j],A[j-1]);
}