修改顺序查找

This commit is contained in:
huihut 2018-03-09 22:41:55 +08:00
parent b43c794c73
commit f36e69d20f
2 changed files with 5 additions and 6 deletions

View File

@ -5,6 +5,7 @@
"xstring": "cpp",
"xtree": "cpp",
"xutility": "cpp",
"iosfwd": "cpp"
"iosfwd": "cpp",
"vector": "cpp"
}
}

View File

@ -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;
}