cautare in vector

#include<iostream.h>
#include<conio.h>
typedef int vector[20];
int n;vector v;

int e(int n,int x)
{
if (n==0) return 0;
else
if (v[n]==x) return 1;
else return e(n-1,x);
}

void main()
{
int x,i;
cout<<“n=”;cin>>n;
cout<<“x=”;cin>>x;
for(i=1;i<=n;i++) {cout<<“v[“<<i<<“]=”;cin>>v[i];}
if (e(n,x)) cout<<“este”<<endl;
else cout<<“nu este”;
getch();
}

Leave a Comment