C自带排序函数qsort()的使用
2010-04-19 13:39
183 查看
stdlib.h中提供了qsort()这个函数可以实现快速排序。
MSDN中的描述如下:
void qsort( void *base, size_t num, size_t width, int (__cdecl *compare )(const void *elem1, const void *elem2 ) );
Parameters
base
Start of target array
num
Array size in elements
width
Element size in bytes
compare
Comparison function
elem1
Pointer to the key for the search
elem2
Pointer to the array element to be compared with the key
Remarks
The qsort function implements a quick-sort algorithm to sort an array of num elements, each of width bytes. The argument base is a pointer to the base of the array to be sorted. qsort overwrites this array with the sorted elements. The argument compare is a pointer to a user-supplied routine that compares two array elements and returns a value specifying their relationship. qsort calls the compare routine one or more times during the sort, passing pointers to two array elements on each call:
compare( (void *) elem1, (void *) elem2 );
MSDN中的描述如下:
void qsort( void *base, size_t num, size_t width, int (__cdecl *compare )(const void *elem1, const void *elem2 ) );
Parameters
base
Start of target array
num
Array size in elements
width
Element size in bytes
compare
Comparison function
elem1
Pointer to the key for the search
elem2
Pointer to the array element to be compared with the key
Remarks
The qsort function implements a quick-sort algorithm to sort an array of num elements, each of width bytes. The argument base is a pointer to the base of the array to be sorted. qsort overwrites this array with the sorted elements. The argument compare is a pointer to a user-supplied routine that compares two array elements and returns a value specifying their relationship. qsort calls the compare routine one or more times during the sort, passing pointers to two array elements on each call:
compare( (void *) elem1, (void *) elem2 );
相关文章推荐
- C自带排序函数qsort()的使用
- qsort的使用以及*(char**)p与(char*)p之间的区别
- 在c++中qsort()排序函数的使用qsort函数应用大全
- C库函数qsort七种使用方法示例
- 关于标准库函数qsort()的使用
- ***快排sort与qsort的使用
- 关于qsort使用时出现的一个问题
- C++ 排序函数 sort(),qsort()的使用方法
- 浅谈C++中qsort与sort的使用方法与区别
- 使用qsort对二维字符数组排序疑难问题调试及解决过程
- milk2<uscao>1.2-<涉及指针是qsort的使用>
- QDirModel使用QSortFilterProxyModel过滤指定磁盘和非系统盘
- 使用qsort实现快速排序
- 使用qsort对结构体的数据排序
- C库函数 qsort 七种使用方法示例
- C库函数qsort七种使用方法示例
- qsort(…)的使用方法
- C/C++中关于qsort的使用
- qsort函数和bsearch函数的使用
- qsort函数使用