提交 97d06589 编写于 作者: 辉哈's avatar 辉哈

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

上级 bcc6a28c
......@@ -11,6 +11,7 @@
"streambuf": "cpp",
"tuple": "cpp",
"system_error": "cpp",
"xtr1common": "cpp"
"xtr1common": "cpp",
"limits": "cpp"
}
}
\ No newline at end of file
// 冒泡排序
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) {
......
// 冒泡排序(改进版)
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) {
......
// 选择排序
void SelectionSort(vector<int>& v) {
if (v.size() <= 0)
return;
int min, temp;
for (int i = 0; i < v.size() - 1; ++i) {
min = i;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册