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 |
Re:Re 为什么会错??偶是新手高人们帮偶看看In Reply To:Re 为什么会错??偶是新手高人们帮偶看看 Posted by:guanlianjun at 2007-06-07 00:07:54 冒泡太慢了;用快排! void SWAP(int &a,int &b) { int p; p=a; a=b; b=p; } void quicksort(int list[ ], int left, int right) { int pivot, i, j ; if ( left < right ){ i=left; j=right+1; pivot=list[left]; do{ do i++; while (list[ i ]< pivot); do j--; while (list[ j ]> pivot); if ( i < j )SWAP(list [ i ],list [ j ]); } while ( i < j ); SWAP( list [ left ], list [ j ]); quicksort( list, left, j-1); quicksort( list, j+1, right); } } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator