修改冒泡选择排序的边界值检测

This commit is contained in:
huihut 2018-03-20 10:34:21 +08:00
parent bcc6a28cd1
commit 97d065894c
4 changed files with 8 additions and 1 deletions

View File

@ -11,6 +11,7 @@
"streambuf": "cpp",
"tuple": "cpp",
"system_error": "cpp",
"xtr1common": "cpp"
"xtr1common": "cpp",
"limits": "cpp"
}
}

View File

@ -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) {

View File

@ -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) {

View File

@ -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;