Can someone post a simple example of a Sequential Search searching an array?
I'm trying to use this:
1 2 3 4 5 6 7 8 9
int SequentialSearch(const vector<int> &radicalone, int search)
{
int i;
int z;
for(i=0;i<radicalone.size();i++)
if(search == radicalone[i])
z ++;
return z;
}
It's supposed to return the amount of times a number is in the array, but I don't know what to do in the main function?
int SequentialSearch(const std::vector<int> &radicalone, int search)
{
int i;
int z = 0;// you should inititalize this
for(i=0;i<radicalone.size();i++)
if(search == radicalone[i])
z ++;
return z;
}
int main()
{
std::vector<int> s(2,5);//create a vector containting {5,5} as elements
std::cout<< SequentialSearch(s,5);
}