2018-02-11 01:08:43 +08:00
|
|
|
// 顺序查找
|
|
|
|
int SequentialSearch(vector<int>& v, int k) {
|
2018-03-09 22:41:55 +08:00
|
|
|
for (int i = 0; i < v.size(); ++i)
|
|
|
|
if (v[i] == k)
|
2018-02-11 01:08:43 +08:00
|
|
|
return i;
|
2018-03-09 22:41:55 +08:00
|
|
|
return -1;
|
2018-02-11 01:08:43 +08:00
|
|
|
}
|