-
C#排序算法 之 插入排序
- using System;
-
- namespace InsertionSorter
- {
- public class InsertionSorter
- {
- public void Sort(int [] list)
- {
- for(int i=1;i<list.Length;i++)
- {
- int t=list[i];
- int j=i;
- while((j>0)&&(list[j-1]>t))
- {
- list[j]=list[j-1];
- --j;
- }
- list[j]=t;
- }
- }
- }
-
- public class MainClass
- {
- public static void Main()
- {
- int[] iArrary=new int[]{1,13,3,6,10,55,98,2,87,12,34,75,33,47};
- InsertionSorter ii=new InsertionSorter();
- ii.Sort(iArrary);
- for(int m=0;m<iArrary.Length;m++)
- {
- Console.Write("{0}",iArrary[m]);
- Console.WriteLine();
- }
- }
- }
- }
-
相关阅读:
【LeetCode 104_二叉树_遍历】Maximum Depth of Binary Tree
【LeetCode 110_二叉树_遍历】Balanced Binary Tree
【LeetCode 111_二叉树_遍历】Minimum Depth of Binary Tree
【剑指Offer】36两个链表的第一个公共结点
【剑指Offer】34第一个只出现一次的字符
【剑指Offer】33丑数
【剑指Offer】32把数组排成最小的数
xgboost的原理没你想像的那么难(转载)
【剑指Offer】31整数中1出现的次数(从1到n整数中1出现的次数)
【剑指Offer】28连续子数组的最大和
-
原文地址:https://www.cnblogs.com/encounter/p/2188847.html
Copyright © 2020-2023
润新知