Skip to content

Commit

Permalink
修改冒泡选择排序的边界值检测
Browse files Browse the repository at this point in the history
  • Loading branch information
huihut committed Mar 20, 2018
1 parent bcc6a28 commit 97d0658
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 1 deletion.
3 changes: 2 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"streambuf": "cpp",
"tuple": "cpp",
"system_error": "cpp",
"xtr1common": "cpp"
"xtr1common": "cpp",
"limits": "cpp"
}
}
2 changes: 2 additions & 0 deletions Algorithm/BubbleSort.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
// 冒泡排序
void BubbleSort(vector<int>& v) {
if (v.size() <= 0)
return;
int temp;
for (int i = 0; i < v.size() - 1; ++i) {
for (int j = 0; j < v.size() - 1 - i; ++j) {
Expand Down
2 changes: 2 additions & 0 deletions Algorithm/BubbleSort_orderly.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
// 冒泡排序(改进版)
void BubbleSort_orderly(vector<int>& v) {
if (v.size() <= 0)
return;
int temp;
bool orderly = false;
for (int i = 0; i < v.size() - 1 && !orderly; ++i) {
Expand Down
2 changes: 2 additions & 0 deletions Algorithm/SelectionSort.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
// 选择排序
void SelectionSort(vector<int>& v) {
if (v.size() <= 0)
return;
int min, temp;
for (int i = 0; i < v.size() - 1; ++i) {
min = i;
Expand Down

0 comments on commit 97d0658

Please sign in to comment.