mirror of
https://github.com/huihut/interview.git
synced 2024-03-22 13:10:48 +08:00
修改顺序查找
This commit is contained in:
parent
b43c794c73
commit
f36e69d20f
3
.vscode/settings.json
vendored
3
.vscode/settings.json
vendored
|
@ -5,6 +5,7 @@
|
|||
"xstring": "cpp",
|
||||
"xtree": "cpp",
|
||||
"xutility": "cpp",
|
||||
"iosfwd": "cpp"
|
||||
"iosfwd": "cpp",
|
||||
"vector": "cpp"
|
||||
}
|
||||
}
|
|
@ -1,9 +1,7 @@
|
|||
// 顺序查找
|
||||
int SequentialSearch(vector<int>& v, int k) {
|
||||
int i = 0;
|
||||
for (; i < v.size(); ++i)
|
||||
for (int i = 0; i < v.size(); ++i)
|
||||
if (v[i] == k)
|
||||
return i;
|
||||
if (i == v.size())
|
||||
return -1;
|
||||
return -1;
|
||||
}
|
Loading…
Reference in New Issue
Block a user