1. Quick Sort
void quick_sort(int bb, int ee) { if( bb < ee ) { int b = bb+1, e = ee, m = (bb+ee) / 2;; int temp = A[bb]; A[bb] = A[m]; A[m] = temp; while( b <= e ) { while( b <= e && A[b] <= A[bb] ) b++; while( b <= e && A[bb] <= A[e] ) e--; if( b < e ) { temp = A[b]; A[b] = A[e]; A[e] = temp; b++, e--; } } temp = A[bb]; A[bb] = A[e]; A[e] = temp; quick_sort( bb, e-1 ); quick_sort( e+1, ee); } }
댓글 없음:
댓글 쓰기