#include<iostream>
using namespace std;
int Search(int* L, int x)
{
int len = sizeof(L) / sizeof(int);
int j = 0;
while (j<len && x>L[j])
{
j = j + 1;
}
if (x < L[j] || j >= len)
{
j = -1;
}
return j;
}
int main()
{
int a[] = { 1,2,3,55,67 };
int res = Search(a, 15);
cout << res;
system("pause");
return 0;
}
030.顺序搜索
最新推荐文章于 2022-07-11 14:17:21 发布