| ||||||||||
| 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 | |||||||||
为什么我用快速排序居然会出现Time Limit Exceed, 难道我的排序算法有错????int partion( int array[], int start, int end )
{
int temple = array[start] ;
while( start < end )
{
while( end > start && array[end] >= temple ) end-- ;
array[start] = array[end] ;
while( start < end && array[start] <= temple ) start++ ;
array[end] = array[start] ;
}
array[end] = temple ;
return end ;
}
void QuickSort( int array[], int start, int end )
{
if( start >= end )
return ;
int middle = partion( array, start, end ) ;
QuickSort( array, start, middle - 1 ) ;
QuickSort( array, middle + 1, end ) ;
}
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator