zoukankan
html css js c++ java
插入排序(C#数据结构学习七)
using
System;
using
System.Collections.Generic;
using
System.Text;
namespace
SoloDataStructure
{
class
MyInsertSort
{
//
插入排序
//
这个简单不多注释
static
void
InsertSort (
int
[] array)
{
//
递增排序
int
temp;
int
i, j,n;
n
=
array.Length;
for
( i
=
1
; i
<
n; i
++
)
{
temp
=
array[i];
//
设置监哨
for
( j
=
i; j
>
0
; j
--
)
if
( temp
<
array[j
-
1
])
array[j]
=
array[j
-
1
];
//
记录后移
else
break
;
array[j]
=
temp;
//
插入array[i];
}
}
static
void
Main(
string
[] args)
{
int
[] arr
=
new
int
[]
{
49
,
38
,
65
,
97
,
76
,
13
,
27
,
49
}
;
Console.Write(
"
原数组数据顺序:
"
);
foreach
(
int
i
in
arr)
{
Console.Write(i
+
"
.
"
);
}
InsertSort(arr);
Console.Write(
"
\n插入排序后数组数据顺序:
"
);
for
(
int
i
=
0
; i
<
arr.Length; i
++
)
Console.Write(arr[i]
+
"
.
"
);
Console.ReadLine();
}
}
}
查看全文
相关阅读:
php笔记--php安装
IEDA-Git的应用
php类型
3.比较与逻辑运算
2.阶乘
1.双分支
013_request对象包含的内容以及获取
011_jsp引入JSTL后实现jsp的解耦
010_jsp引入JSTL
ORACLE1.28 面试题
原文地址:https://www.cnblogs.com/solo/p/609673.html
最新文章
unittest学习3-测试组件setup、teardown
unittest的命令执行
初识unittest
测试用例
接口测试-基础知识1
lua---研究 c-api
Unity---在Hierarchy视图中将选中的对象的层级目录复制到剪切板
Unity --- 设置选择的图片的格式
Unity --- 如何简单的判断图片是否含有 alpha channel
Unity --- 在原目录中,将选中的Texture剥离为rgb和alpha
热门文章
C# --- 可空值类型
C# --- ??(空接合操作符)的一个案例
C#---装箱、拆箱的一个案例
Unity---判断某个点是否在摄像机的视景范围内
java-VMware安装
php-composer使用
php--配置composer插件
php-phpstorm配置php语言
java-ssm简介
php-配置Apache
Copyright © 2011-2022 走看看