排序
YogLn
从入门到放弃的蒟蒻
展开
-
java Arrays.sort()实现降序排列
示例:实现随机数100-900之间的降序排列 package exam4; import java.util.*; public class Arr { public static void main(String[] args) { // TODO 自动生成的方法存根 Scanner reader = new Scanner(System.in);...原创 2019-11-20 22:41:57 · 6813 阅读 · 0 评论 -
堆排序
视频链接:https://www.bilibili.com/video/av47196993?from=search&seid=12418703498405255943 参考代码: #include <iostream> #include <algorithm> //堆heap:1,完全二叉树;2,父节点的值大于子节点得值 //parent=(i-1)/2; //c...原创 2019-09-24 15:24:05 · 108 阅读 · 0 评论 -
归并排序
视频链接:https://www.bilibili.com/video/av9982752?from=search&seid=12418703498405255943 参考代码: #include<cstdio> #include<iostream> using namespace std; const int maxn = 100005; int n; int a...原创 2019-09-24 16:32:25 · 251 阅读 · 0 评论 -
桶排序
#include <iostream> using namespace std; void BucketSort(int *A, int Max, int Size) { int *B=new int [Max + 1]; int i, j, count = 0; memset(B, 0, (Max + 1) * sizeof(int)); for (i = 0; i <...原创 2019-09-24 17:52:29 · 271 阅读 · 0 评论 -
希尔排序
#include <iostream> using namespace std; void shellsort(int A[], int l, int h) { if (l < h) { int d;//增量 int tmp; int j; int size = h - l + 1; for (d = size / 2; d >= 1; d /= 2)...原创 2019-09-25 00:35:35 · 78 阅读 · 0 评论 -
希尔排序(shell_sort)
#include <iostream> using namespace std; int a[] = { 70,30,40,10,80,20,90,100,75,60,45 }; void shell_sort(int a[], int n); int main() { cout << "Before Sort: "; for (int i = 0; i <...原创 2019-09-25 15:15:11 · 166 阅读 · 0 评论 -
插入排序
视频链接:https://www.bilibili.com/video/av47634289?t=460 参考代码: #include <iostream> using namespace std; int a[] = { 70,30,40,10,80,20,90,100,75,60,45 }; void insert_sort(int a[], int n) { for (int ...原创 2019-09-25 15:26:59 · 85 阅读 · 0 评论