Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Walter.Wen
SortAlgorithm
提交
4725073b
S
SortAlgorithm
项目概览
Walter.Wen
/
SortAlgorithm
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
S
SortAlgorithm
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
4725073b
编写于
6月 01, 2019
作者:
W
WalterWen
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
排序算法
上级
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
83 addition
and
0 deletion
+83
-0
.classpath
.classpath
+6
-0
.gitignore
.gitignore
+1
-0
.project
.project
+17
-0
.settings/org.eclipse.jdt.core.prefs
.settings/org.eclipse.jdt.core.prefs
+11
-0
src/com/we/sort/BubbleSort.java
src/com/we/sort/BubbleSort.java
+48
-0
未找到文件。
.classpath
0 → 100644
浏览文件 @
4725073b
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry
kind=
"con"
path=
"org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"
/>
<classpathentry
kind=
"src"
path=
"src"
/>
<classpathentry
kind=
"output"
path=
"bin"
/>
</classpath>
.gitignore
0 → 100644
浏览文件 @
4725073b
/bin/
.project
0 → 100644
浏览文件 @
4725073b
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>
SortAlgorithm
</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>
org.eclipse.jdt.core.javabuilder
</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>
org.eclipse.jdt.core.javanature
</nature>
</natures>
</projectDescription>
.settings/org.eclipse.jdt.core.prefs
0 → 100644
浏览文件 @
4725073b
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
org.eclipse.jdt.core.compiler.compliance=1.8
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
org.eclipse.jdt.core.compiler.debug.localVariable=generate
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.source=1.8
src/com/we/sort/BubbleSort.java
0 → 100644
浏览文件 @
4725073b
package
com.we.sort
;
public
class
BubbleSort
{
public
void
bubbleSort
(
int
[]
list
)
{
for
(
int
i
=
1
;
i
<
list
.
length
;
i
++)
{
// 设定一个标记,若为true,则表示此次循环没有进行交换,也就是待排序列已经有序,排序已经完成。
boolean
flag
=
true
;
for
(
int
j
=
0
;
j
<
list
.
length
-
i
;
j
++)
{
if
(
list
[
j
]
>
list
[
j
+
1
])
{
int
tmp
=
list
[
j
];
list
[
j
]
=
list
[
j
+
1
];
list
[
j
+
1
]
=
tmp
;
flag
=
false
;
}
}
if
(
flag
)
{
break
;
}
System
.
out
.
format
(
"第 %d 趟: "
,
i
);
printAll
(
list
);
}
}
// 打印完整序列
public
void
printAll
(
int
[]
list
)
{
for
(
int
value
:
list
)
{
System
.
out
.
print
(
value
+
" "
);
}
System
.
out
.
println
();
}
public
static
void
main
(
String
[]
args
)
{
int
array
[]
=
{
3
,
44
,
38
,
5
,
47
,
15
,
36
,
26
,
27
,
2
,
46
,
4
,
19
,
50
,
48
};
// 调用冒泡排序方法
BubbleSort
bubble
=
new
BubbleSort
();
System
.
out
.
print
(
"排序前: "
);
bubble
.
printAll
(
array
);
bubble
.
bubbleSort
(
array
);
System
.
out
.
print
(
"排序后: "
);
bubble
.
printAll
(
array
);
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录