c语言 整型数组排序库函数
Prerequisite: std::nth_element() in C++
先决条件: C ++中的std :: nth_element()
Problem statement:
问题陈述:
Find the median of an unsorted array.
查找未排序数组的中位数。
What is median?
什么是中位数?
A median is a statistical measurement that divides an ordered set of data into two halves. Median is the partitioning point for any ordered list. In the case of a sorted array median is the middle element. If the array size is odd then the median is simply the middle element and if the array size is odd then the median is the average of the two middle elements.
中位数是一种统计量度,将有序数据集分为两半。 中位数是任何有序列表的分区点。 在排序数组的情况下,中值是中间元素。 如果数组大小为奇数,则中位数仅是中间元素;如果数组大小为奇数,则中位数为两个中间元素的平均值。
Example:
例:
Array with odd size: