C++临走前奉献:qsort函数的使用方法

来源:百度知道 编辑:UC知道 时间:2024/06/19 10:02:54
*
函数功能:对数组进行排序。

*
函数原型

#include <stdlib.h>
void qsort(void *base, size_t nmemb, size_t size, int (*compar) (const void *, const void *));

*
函数描述

The qsort() function sorts an array with nmemb elements of size size. The base argument points to the start of the array. The contents of the array are sorted in ascending order according to a comparison function pointed to by compar, which is called with two arguments that point to the objects being compared.

The comparison function must return an integer less than, equal to, or greater than zero if the first argument is considered to be respectively less than, equal to, or greater than the second. If two members compare as equal, their order in the sorted array is undefined.
根据字符串长度对字符串排序

说明:对一系列的字符串按每个字符串的长度,由小到大排序,并输出排序后的所有字符串。这里的字符串以命令行参数的形式传递。
qsort-strings-by-length.c

01
02
03
04

记得回来给分啊,我这么支持你。
一定要回来啊。

姜还是老的辣!!

干嘛要走呢,啥意思?

走了?我以为发布问题呢

你的人气还不错。

???李彦?宏??:这么热闹