Skip to content

Commit

Permalink
修改顺序查找
Browse files Browse the repository at this point in the history
  • Loading branch information
huihut committed Mar 9, 2018
1 parent b43c794 commit f36e69d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
3 changes: 2 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"xstring": "cpp",
"xtree": "cpp",
"xutility": "cpp",
"iosfwd": "cpp"
"iosfwd": "cpp",
"vector": "cpp"
}
}
8 changes: 3 additions & 5 deletions Algorithm/SequentialSearch.h
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
// 顺序查找
int SequentialSearch(vector<int>& 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;
}

0 comments on commit f36e69d

Please sign in to comment.