int busca_linear (int v[], int dim, int num)
{
for (int i=0; i<dim; i++)
{
if (v[i]==num)
return i;
}
return -1;
}
int main(int argc, char *argv[])
{
int v[5] = {5,3,1,2,4}, dim=5, num;
cout<< "entre com o numero";
cin>> num;
cout<<"o numero esta na posicao:"; <<busca_linear(v,dim,num)<<"do vetor";
return 0;
}
system("PAUSE");
return EXIT_SUCCESS;
}
I just can't fix it..you might think this is something stupid but I'm new to c++
busca linear = linear search expected primary-expression before '<<' token
I've just changed it but now after pressing f9 I get this message:
expected constructor, destructor, or type conversion before '(' token
#include <cstdlib>
#include <iostream>
using namespace std;
int busca_linear (int v[], int dim, int num)
{
for (int i=0; i<dim; i++)
{
if (v[i]==num)
return i;
}
return -1;
}
int main(int argc, char *argv[])
{
int v[5] = {5,3,1,2,4}, dim=5, num;
cout<< "entre com o numero";
cin>> num;
cout<<"o numero esta na posicao:";
cout<<busca_linear(v,dim,num)<<"do vetor";
return 0;
}