Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
joebiden
interview
提交
a7a6e38c
I
interview
项目概览
joebiden
/
interview
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
I
interview
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
a7a6e38c
编写于
2月 11, 2018
作者:
辉哈
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
更新选择排序
上级
9c123ec7
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
22 addition
and
7 deletion
+22
-7
Algorithm/BubbleSort.h
Algorithm/BubbleSort.h
+0
-1
Algorithm/BubbleSort_orderly.h
Algorithm/BubbleSort_orderly.h
+3
-5
Algorithm/SelectionSort.h
Algorithm/SelectionSort.h
+17
-0
README.md
README.md
+2
-1
未找到文件。
Algorithm/BubbleSort.h
浏览文件 @
a7a6e38c
// 冒泡排序
void
BubbleSort
(
vector
<
int
>&
v
)
{
int
temp
;
for
(
int
i
=
0
;
i
<
v
.
size
()
-
1
;
++
i
)
{
...
...
Algorithm/BubbleSort_orderly.h
浏览文件 @
a7a6e38c
// 冒泡排序(跳过有序的改进版)
// 冒泡排序(改进版)
void
BubbleSort_orderly
(
vector
<
int
>&
v
)
{
int
temp
;
bool
orderly
=
false
;
for
(
int
i
=
0
;
i
<
v
.
size
()
-
1
&&
!
orderly
;
++
i
)
{
orderly
=
true
;
for
(
int
j
=
0
;
j
<
v
.
size
()
-
1
-
i
;
++
j
)
{
if
(
v
[
j
]
>
v
[
j
+
1
])
{
orderly
=
false
;
if
(
v
[
j
]
>
v
[
j
+
1
])
{
// 从小到大
orderly
=
false
;
// 发生交换则仍非有序
temp
=
v
[
j
];
v
[
j
]
=
v
[
j
+
1
];
v
[
j
+
1
]
=
temp
;
...
...
Algorithm/SelectionSort.h
0 → 100644
浏览文件 @
a7a6e38c
// 选择排序
void
SelectionSort
(
vector
<
int
>&
v
)
{
int
min
,
temp
;
for
(
int
i
=
0
;
i
<
v
.
size
()
-
1
;
++
i
)
{
min
=
i
;
for
(
int
j
=
i
+
1
;
j
<
v
.
size
();
++
j
)
{
if
(
v
[
j
]
<
v
[
min
])
{
// 标记最小的
min
=
j
;
}
}
if
(
i
!=
min
)
{
// 交换到前面
temp
=
v
[
i
];
v
[
i
]
=
v
[
min
];
v
[
min
]
=
temp
;
}
}
}
\ No newline at end of file
README.md
浏览文件 @
a7a6e38c
...
...
@@ -43,7 +43,8 @@
### 排序
*
[
冒泡排序
](
Algorithm/BubbleSort.h
)
*
[
冒泡排序(跳过有序的改进版)
](
Algorithm/BubbleSort_orderly.h
)
*
[
冒泡排序(改进版)
](
Algorithm/BubbleSort_orderly.h
)
*
[
选择排序
](
Algorithm/BubbleSort_orderly.h
)
## Problems
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录