快排原函數
void qsort(void * array,int nelem,int width,int (* fcmp)(const void *,const void *));
參數分別爲:數組名,數組元素個數,單個元素所屬數據類型的長度(字節數),比較函數
如果是整型數組排序,比較函數可以這樣寫
int comp(const void * a,const void *b)
{
return *(int *)a-*(int * )b;
}
這個比較函數原方不動的寫main函數前面即可,函數調用時這樣寫:
qsort(a,100,sizeof(int),comp);
就是給a[100]這個數組排序
STL 快速排序
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章
POJ3096—Surprising Strings
X维
2020-07-08 09:21:00
map使用手冊
chosethisway
2020-07-08 05:35:16
封裝統一模板調用動態庫(dll)
yu_sn0w
2020-07-07 13:31:31
Windows 下動態庫的 DllMain 與 c++ 相關坑
yu_sn0w
2020-07-07 13:31:31
VC++ STL理論介紹
Antares_SANTALEN
2020-07-07 13:28:01
STL--deque容器
。。
2020-07-07 13:27:47
STL容器--queue
。。
2020-07-07 13:27:44
STL----map容器
。。
2020-07-07 13:27:44
STL --string容器
。。
2020-07-07 13:27:41
STL----set容器
。。
2020-07-07 13:27:40
STL容器--stack
。。
2020-07-07 13:27:38
STL -- vector容器
。。
2020-07-07 13:27:38
STL學習小記--順序容器
STL中的順序容器有: vector //支持快速隨機訪問 list //支持快速插入刪除 deque //雙端隊列 順序容器適配器: stack //LIFO queu
子目
2020-07-07 12:34:49
codeforces 742B - Arpa’s obvious problem and Mehrdad’s terrible solution
菜逼一枚
2020-07-07 11:30:46