Psst.. new poll here.
Psst.. new forums here.
Microsoft is blocking us again (TY IP Reputation!) so just use oauth login instead. :)
Paste
Pasted as C++ by tai ( 5 years ago )
void QuickSort(int *a, int n)
{
int left = 0;
int right = n - 1;
int mid = (left + right) / 2;
int x = a[mid];
int i = left, j = right;
while(i < j)
{
/*Bên trái là các phần tử <= a[mid]*/
while(i <= mid)
{
if(a[i] >= x)
{
break;
}
else
{
i++;
}
}
/*Bên phải là các phần tử > a[mid]*/
while(j >= mid)
{
if(a[j] <= x)
{
break;
}
else
{
j--;
}
}
Swap(a[i], a[j]);
i++;
j--;
cout << endl;
Output_Array(a, n);
cout << endl;
}
}
Revise this Paste