void quicksort(int left, int right)
{
int i, j, x;
i = left;
j = right;
if(i >= j) return;
x = a[i];
while(i < j)
{
while(i < j && a[j] > x) j--;
if(i < j) a[i++] = a[j];
while(i < j && a[i] < x) i++;
if(i < j) a[j--] = a[i];
}
a[i] = x;
if(left < i - 1) quicksort(left, i - 1);
if(i + 1 < right) quicksort(i + 1, right);
}