zoukankan
html css js c++ java
冒泡排序(C#数据结构学习九)
using
System;
using
System.Collections.Generic;
using
System.Text;
namespace
SoloDataStructure
{
class
MyBubbleSort
{
//
冒泡排序
static
void
BubbleSort(
int
[] arr)
{
int
n
=
arr.Length;
for
(
int
i
=
0
; i
<
n
-
1
; i
++
)
//
做n-1趟排序
{
bool
noswap
=
true
;
//
未交换标志
for
(
int
j
=
n
-
1
; j
>
i; j
--
)
{
if
(arr[j]
<
arr[j
-
1
])
{
//
swap记录
int
temp
=
arr[j];
arr[j]
=
arr[j
-
1
];
arr[j
-
1
]
=
temp;
noswap
=
false
;
}
}
if
(noswap)
return
;
}
}
static
void
Main(
string
[] args)
{
int
[] arr
=
new
int
[]
{
99
,
88
,
4
,
9
,
2
,
77
,
32
,
11
,
46
}
;
BubbleSort(arr);
Console.Write(
"
Data After BubbleSort:
"
);
foreach
(
int
i
in
arr)
{
Console.Write(i
+
"
,
"
);
}
Console.ReadLine();
}
}
}
查看全文
相关阅读:
水晶苍蝇拍:从“航空母舰”看企业竞争优势分析 (2010-05-11 11:48:38)
水晶苍蝇拍:为何设定了安全边际后还吃大跌?
水晶苍蝇拍:“低风险,高不确定性”的启示 (2010-04-24 22:02:13)
水晶苍蝇拍:我这样看投资的安全性 (2009-08-27 20:08:53)
水晶苍蝇拍:不同企业的估值差告诉我们什么? (2010-04-21 20:56:19)
水晶苍蝇拍:估值,像雾像雨又像风 (2010-03-15 10:44:16)
水晶苍蝇拍:长持的简单逻辑 (2009-05-25 18:08:43)
Android中RelativeLayout各个属性的含义
有道词典 Andriod 版本数据格式分析
电驴提示“该内容尚未提供权利证明,无法提供下载”之解决办法详解
原文地址:https://www.cnblogs.com/solo/p/610138.html
最新文章
高等数学、线性代数、概率论数理统计书籍推荐
计算机视觉、机器学习、图形学等学习资料网站
impetus
Microsoft glTF-SDK
基于物理着色(四)- 次表面散射
computer-graphics-fall-2012/lecture-notes/
免费的计算机编程类中文书籍
Leetcode 162.寻找峰值
卷积神经网络各种池化
图卷积神经网络
热门文章
Leetcode 91.解码方法
Leetcode 153.寻找旋转数组中的最小值
Leetcode 152.乘机最大子序列
Leetcode 150.逆波兰表达式求值
Leetcode 149.直线上最多的点数
Leetcode 148.排序链表
Leetcode 147.对链表进行排序
水晶苍蝇拍:《漫步华尔街》之辩:技术分析不可依靠(上) (2010-03-22 11:21:49)
水晶苍蝇拍:价值投资的“基础,重点和核心” (2010-06-23 18:30:07)
水晶苍蝇拍:建立自己的“财富正循环体系” (2010-05-16 10:59:37)
Copyright © 2011-2022 走看看