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();
}
}
}
查看全文
相关阅读:
MySQL主从配置
MySQL操作
初识数据库
Session对象以及其常用的方法
请求重定向与请求转发的区别
JSP respone常用方法
解决JSP url传值中文乱码问题
JSP request 对象
JSP 内置对象get 和 post的区别
jsp out对象
原文地址:https://www.cnblogs.com/solo/p/610138.html
最新文章
C# Newtonsoft.Json解析数组的小例子
TypedArray.prototype.includes()
UI設計網址大全
NPOI操作Excel
sdnu 1078.食物链(种类并查集)
Constructing Roads
Jungle Roads
Networking (最小生成树)
HDU 1556 Color the ball(树状数组)
HDU
热门文章
CodeForces
CodeForces
CodeForces
CodeForces
zookeeper and kafka
Go语言标准库flag基本使用
Go标准库之Context
[已解决]Mac 升级至10.15 VM 出现黑屏等
go之二进制协议gob和msgpack
snowflake 雪花算法 分布式实现全局id生成
Copyright © 2011-2022 走看看