Hello to you all ,

i have recieved an assignment to build a recursive function
which will recieve an array which has to check if it is "Up&Down" from both sides : Example : 2 5 6 12 7 5 2 .
according to the specs of the H.W assignment , i need to find an "extreme value" (in example - 12) .

how should i approach this?

Thank you

Yotam

Member Avatar for iamthwee

Hello to you all ,

i have recieved an assignment to build a recursive function
which will recieve an array which has to check if it is "Up&Down" from both sides : Example : 2 5 6 12 7 5 2 .
according to the specs of the H.W assignment , i need to find an "extreme value" (in example - 12) .

how should i approach this?

Thank you

Yotam

up&down - makes perfect sense now :rolleyes:

pls try this code.

#include <iostream.h>
#include <conio.h>
int ext(int[],int,int);
void main()
{
int k,a[10],i,n,p=0;
clrscr();
cout<<"Enter size of array	:";
cin>>n;
cout<<"Enter the elements	:";
for (i=0;i<n;i++)
 cin>>a[i];
 k=ext(a,n,p);
 cout<<"The extreme element is 		:"<<k;
 getch();
 }

 int ext(int a[10],int n,int pos)
 {
  if (pos<=n)
   {
   --n;
   ++pos;
    ext(a,n,pos);
      }

   return a[++pos];
   }
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.