就乙個快速排序。。。

2021-06-29 14:59:54 字數 501 閱讀 7027

話說,每次寫題的時候我都是呼叫stl的sort,自己卻還是很難快速寫出乙個快排。。正好作業布置這個了。。就寫一下,熟練一下,順便背一下記住。。

萬一以後面試問到了,也可以秒了。。

#include #include #include using namespace std;

const int maxn = 10000 + 5;

double a[maxn];

template t part(t a, int p, int r)

a[p] = a[j];

a[j] = x;

return j;

}template void quicksort(t a, int p, int r)

}int main()

quicksort(a, 0, cnt - 1);

for(int i = 0; i < cnt; i++)

return 0;

}

乙個快速排序的小技巧

最近在設計的 中有這麼乙個要求,有一堆字串,如 a 1 a 3 a 5 a 2 假設字首都是a,並且中括號中的數值沒有重複 現在要用程式將可以合併的陣列都合併起來,變成 a 1.3 a 5 那麼我想到的辦法是這樣的,將中括號中的數字提取出來,放在乙個list中,然後對list排序,也就是說上述資料排...

自己寫的乙個快速排序

呵呵 今天沒事看了看 快速排序的基本思想後寫了乙個快排的demo 發到部落格上做個備份 public class quicksort public static void quicksort int l,int u int m l for int i l 1 i u i swap l,m quick...

自己寫的乙個快速排序

include stdafx.h include include include using namespace std define maxtcpconnect 1000 struct remotesockinfo struct mylist typedef mylist pmylist void...