1. 程式人生 > >我愛看歐文打球

我愛看歐文打球

int partition(int *l,int low,int high) {
	int temp=l[low];
	int p = l[low];
	while (low != high) {
		while (low < high&&l[high] <= p) {
			high--;
		}
		l[low] = l[high];
		while (low < high&&l[low] >= p) {
			low++;
		}
		l[high] = l[low];
		
	}
	l[low] = temp;
	return low;


}
void qsort(int *l, int low, int high) {
	int p;
	if(low<high){
		p = partition(l,low,high);
		qsort(l, low, p - 1);
		qsort(l, p + 1, high);
	}
}