直接插入排序
来源:互联网 发布:三菱plc编程手册哪里有 编辑:程序博客网 时间:2024/05/21 07:00
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace 直接插入排序
{
class Program
{
static void Main(string[] args)
{
int []s= { 10,30,65964,12,64,1,3,9,75,94,110};
int temp;
for(int i=1;i<s.Length;i++)
{
for(int j=i;j>0;j--)//这里注意就J>0;之前我写成了>=0;那么会导致在循环遍历的时候可能
{
if(s[j]>s[j-1])
{
temp = s[j];
s[j] = s[j-1 ];
s[j - 1] = temp;
}
else
{
break;
}
}
}
for (int i = 0; i < s.Length; i++)
{
Console.Write(s[i]+" ");
}
Console.ReadKey();
}
}
}
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace 直接插入排序
{
class Program
{
static void Main(string[] args)
{
int []s= { 10,30,65964,12,64,1,3,9,75,94,110};
int temp;
for(int i=1;i<s.Length;i++)
{
for(int j=i;j>0;j--)//这里注意就J>0;之前我写成了>=0;那么会导致在循环遍历的时候可能
{
if(s[j]>s[j-1])
{
temp = s[j];
s[j] = s[j-1 ];
s[j - 1] = temp;
}
else
{
break;
}
}
}
for (int i = 0; i < s.Length; i++)
{
Console.Write(s[i]+" ");
}
Console.ReadKey();
}
}
}
0 0
- 插入排序--直接插入
- 插入排序------直接插入
- 插入排序---直接插入
- 排序:直接插入排序
- 排序---直接插入排序
- 排序 -- 直接插入排序
- 排序---直接插入排序
- 排序--直接插入排序
- 排序-直接插入排序
- 【排序】直接插入排序
- 排序--直接插入排序
- 排序:直接插入排序
- 【排序】直接插入排序
- 排序--直接插入排序
- 排序--直接插入排序
- 排序-直接插入排序
- 插入排序--直接插入排序
- 插入排序-直接插入排序
- 排序数组合并
- leetcode_378 Kth Smallest Element in a Sorted Matrix
- php服务器需要定时刷新数据库问题
- CUDA入门(六) 异步并行执行解析
- 动态分配
- 直接插入排序
- struts2中s:select标签的使用
- HDU 1159 Common Subsequence(LCS)
- Java设计模式—观察者(Observer)
- 行政区域划分
- 顺势而为,HTML发展与UI组件设计进化
- 根据nameSpace赋指定材质
- LG的数学计划----分解质因数(Pollard-Rho算法)
- C语言中strlen、strcpy、strncpy、strcat、strnact、strcmp、memcpy函数的实现