![](https://img-blog.csdnimg.cn/20201014180756926.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
排序
Error Man
我是菜逼
展开
-
归并排序(求逆序对)
#include<stdio.h>const int MX = 1e3 + 5;int T[MX];void _sort(int A[], int l, int r) { //排序的区间为l至r; if(l == r) return ; //如果l==r,意思是只有一个数,无需排序; int m = (l + r) /...原创 2018-07-25 13:41:51 · 207 阅读 · 0 评论 -
快速排序模版
void quick_sort(int a[], int low, int high) { int i = low, j = high; int t = a[i]; if(low < high) { while(i < j) { while(t <= a[j] && i < j) {//从右往...原创 2018-07-25 13:44:12 · 139 阅读 · 0 评论 -
Gym - 101466 J. Jeronimo's List (桶排序)
Jeronimo the bear loves numbers and he is planning to writennumbers in his notebook.After writing the firstmnumbers, Jeronimo felt that he was spending a lot of time thinking new numbers, so he ...原创 2018-08-19 16:55:19 · 289 阅读 · 0 评论 -
桶排序
桶排序,其大概原理如下。。。(这是对于没有负数的情况)如需要排序的值为 a[] = { 10, 4,20, 10, 50 ,100 };100为其中的最大值,所以我们需要开一个 101大的数组,也就是桶的数量。还需要一个 num 数组来记录 每个数出现的次数,//不要num 一样的,num[] == 0 , 就代表没有出现咯for(0 to n) //n 代...原创 2018-08-19 16:47:18 · 179 阅读 · 0 评论