1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
|
#include <iostream>
#include <cassert>
using namespace std;
int maxx=22 ;
int length;
int vettore[]={5,12,33,55,23,12,1,12,45,0,56,6864,78,55,123,456,74,1,0,2,0,1};
int number,booleano;
/***************************** function***********************************/
int fRic(int numero,int array[],int indice) //HERE ARE THE PROBLEM!!
{
if (indice==0) //base for function
{
if (array[indice]==numero)
return 1;
}
else
return fRic(number,vettore, length-1); //recursion
}
/************************ start program ***************************************/
int main()
{
while(true)
{
length=maxx;
cout<<"inserisci il numero da ricercare: "<<'\n';
cin>>number;
assert(number>=0);
cout<<fRic(number,vettore,length)<<'\n';
}
return 0;
}
|