最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

什么排序算法做的qsort使用?

SEO心得admin149浏览0评论
本文介绍了什么排序算法做的qsort使用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我找不到任何有关的信息排序什么算法的C 的qsort 函数使用。

I can't find any information regarding what sorting algorithm C qsort function uses.

它是快速排序?它不是在人提到

Is it quicksort? It is not mentioned in man.

推荐答案

没有指定的qsort 的实施:实施可以使用任何排序算法。有趣的是,排序并不需要是稳定的,并且没有复杂的要求。

The implementation of qsort is not specified: an implementation may use any sorting algorithm. Interestingly, the sort does not need to be stable, and there is no complexity requirement.

的qsort (C11§7.22.5.2)的全部规格如下:

The entire specification of qsort (C11 §7.22.5.2) is as follows:

的的qsort 函数

The qsort function

简介

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

    

说明

的的qsort 函数对 nmemb个对象的数组,最初的元素,它是  通过基地指向。由指定的每个对象的大小尺寸。

The qsort function sorts an array of nmemb objects, the initial element of which is pointed to by base. The size of each object is specified by size.

阵列的内容被根据一个比较函数按升序排列指向COMPAR,称为使用两个参数指向的对象被比较。如果第一个参数被认为是比大于第二分别小于,等于或大于该函数将返回小于一个整数,等于或大于零。

The contents of the array are sorted into 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 function shall 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 elements compare as equal, their order in the resulting sorted array is unspecified.

返回

的的qsort 函数返回值。

发布评论

评论列表(0)

  1. 暂无评论