#include <iostream>
using namespace std;
int SeqSearch(int r[], int n, int k)//r[1]~r[n]存放元素
{
int i = n;
r[0] = k;
while(r[i]!=k)
{
i--;
}
return i;
}
int main()
{
int r[] = {0,3,9,6,45,32,68};
int i = SeqSearch(r,6,74);
if(i == 0)
{
cout<<"no result fetched...";
}
else
{
cout<<"success"<<endl;
}
return 0;
}
C++ 顺序表的查找
最新推荐文章于 2023-03-26 20:20:57 发布