| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
而且相差也太大了!用自带的qsort运行时间是407MS,自己写的快排居然2000MS Timeout。In Reply To:Re:无语,自己写的快排就是没有自带的快,一换qsort就过…… Posted by:yinyueyouge at 2008-03-07 17:25:41 差距那么大么?
我写的快排:
void swap(int *a, int *b) {
int t=*a; *a=*b; *b=t;
}
void quickSort(int arr[], int beg, int end) {
if (end > beg + 1) {
int piv = arr[beg], l = beg + 1, r = end;
while (l < r) {
if (arr[l] <= piv)
l++;
else
swap(&arr[l], &arr[--r]);
}
swap(&arr[--l], &arr[beg]);
quickSort(arr, beg, l);
quickSort(arr, r, end);
}
}
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator