From 97d065894cca6b4af33e15b881d605b52ebd89a0 Mon Sep 17 00:00:00 2001 From: huihut Date: Tue, 20 Mar 2018 10:34:21 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=86=92=E6=B3=A1=E9=80=89?= =?UTF-8?q?=E6=8B=A9=E6=8E=92=E5=BA=8F=E7=9A=84=E8=BE=B9=E7=95=8C=E5=80=BC?= =?UTF-8?q?=E6=A3=80=E6=B5=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .vscode/settings.json | 3 ++- Algorithm/BubbleSort.h | 2 ++ Algorithm/BubbleSort_orderly.h | 2 ++ Algorithm/SelectionSort.h | 2 ++ 4 files changed, 8 insertions(+), 1 deletion(-) diff --git a/.vscode/settings.json b/.vscode/settings.json index 1489981..e627288 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -11,6 +11,7 @@ "streambuf": "cpp", "tuple": "cpp", "system_error": "cpp", - "xtr1common": "cpp" + "xtr1common": "cpp", + "limits": "cpp" } } \ No newline at end of file diff --git a/Algorithm/BubbleSort.h b/Algorithm/BubbleSort.h index c787fcb..3270519 100644 --- a/Algorithm/BubbleSort.h +++ b/Algorithm/BubbleSort.h @@ -1,5 +1,7 @@ // 冒泡排序 void BubbleSort(vector& 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) { diff --git a/Algorithm/BubbleSort_orderly.h b/Algorithm/BubbleSort_orderly.h index 5c39409..91ef293 100644 --- a/Algorithm/BubbleSort_orderly.h +++ b/Algorithm/BubbleSort_orderly.h @@ -1,5 +1,7 @@ // 冒泡排序(改进版) void BubbleSort_orderly(vector& v) { + if (v.size() <= 0) + return; int temp; bool orderly = false; for (int i = 0; i < v.size() - 1 && !orderly; ++i) { diff --git a/Algorithm/SelectionSort.h b/Algorithm/SelectionSort.h index d9c7b1e..3f3c70c 100644 --- a/Algorithm/SelectionSort.h +++ b/Algorithm/SelectionSort.h @@ -1,5 +1,7 @@ // 选择排序 void SelectionSort(vector& v) { + if (v.size() <= 0) + return; int min, temp; for (int i = 0; i < v.size() - 1; ++i) { min = i;