diff --git a/.vscode/settings.json b/.vscode/settings.json index f30c192..914dae3 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -5,6 +5,7 @@ "xstring": "cpp", "xtree": "cpp", "xutility": "cpp", - "iosfwd": "cpp" + "iosfwd": "cpp", + "vector": "cpp" } } \ No newline at end of file diff --git a/Algorithm/SequentialSearch.h b/Algorithm/SequentialSearch.h index bef7ced..28fd335 100644 --- a/Algorithm/SequentialSearch.h +++ b/Algorithm/SequentialSearch.h @@ -1,9 +1,7 @@ // 顺序查找 int SequentialSearch(vector& v, int k) { - int i = 0; - for (; i < v.size(); ++i) - if (v[i] == k) + for (int i = 0; i < v.size(); ++i) + if (v[i] == k) return i; - if (i == v.size()) - return -1; + return -1; } \ No newline at end of file