Computer Science, asked by gauravsaini6590, 1 year ago

Given an array of length n and an integer x, you need to find all the indexes where x is present in the input array. Save all the indexes in an array (in increasing order). Do this recursively. Indexing in the array starts from 0.

Answers

Answered by RudraPratapSingh456
0

Answer:

be sure to be able to make I will explain to you and I have my phone is that

Answered by Deepanshuchhillar
0

#include<iostream>

using namespace std;

int sest(int *arr, int size, int num, int *out)

{

   static int i=0;

   static int k=1;

   if(size>0)

   {

       if(*arr==num)

   {

     *out=i;

      out=out+1;

      k++;

     

   }

      i++;      

      sest(arr+1,size-1,num,out);

   }

   

  return k-1;

   

}

void display(int k, int *out)

{

   for(int i=0;i<k;i++)

   {

       cout<<out[i]<<" ";

   }

}

int main()

{

   int arr[]={6,5,9,5,6,5,6,6,6};

   int size= sizeof(arr)/sizeof(arr[0]);

   int out[size]={0};

 // sest gives how many times number have appeared

// calling for number 6

   int times = sest(arr,size,6,out);

   

   display(times,out);

   

   return 7566;

}

Similar questions