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();
}
}
}
查看全文
相关阅读:
YII 视图层的超链接不会正常显示了
GIT 命令大全详解
git将一个分支完全覆盖另外一个分支如:stable分支代码完全覆盖brush分支
MySQL 查询日志
Yii 数据库查看保存数据时发生的错误
Hyperledger Fabric(3)通道与组织
Hyperledger Fabric(2)共识与交易
Hyperledger Fabric(1)基础架构
Hyperledger Fabric 环境搭建(2)
Hyperledger Fabric 环境搭建(1)
原文地址:https://www.cnblogs.com/solo/p/610138.html
最新文章
ASP.NET 事务使用,
MAC os x 下 python-nmap 安装问题总结
windows 学习命令 记录
youtube 上视频下载(免费的视频)
Json对象、 Json纯文本 和js对象的区别:
Jenkins+jmeter设置定时执行任务
jmeter的关联
jmeter常用定时器以及事物控制器
jmeter之断言
jmeter之参数化
热门文章
jmeter如何解决乱码问题
HTTP协议
性能测试基础
Monkey命令参数介绍
APP测试
git 远程代码回滚master
MySQL 查询某一字段为数字的数据
阿里云日志添加要查询字段
phpstrom 本地编辑玩文件 自动临时映射到远程服务器
MySQL find_in_set
Copyright © 2011-2022 走看看