- Strength to Increase Rep
- +0
- Strength to Decrease Rep
- -0
- Upvotes Received
- 1
- Posts with Upvotes
- 1
- Upvoting Members
- 1
- Downvotes Received
- 6
- Posts with Downvotes
- 5
- Downvoting Members
- 4
3 Posted Topics
How can i print it recursively with one helper function? [img]http://img2.imageshack.us/img2/1690/recursive.th.jpg[/img] Here, n will always be a power of 2 and c will be indicating the column number from which to start the output. The above pattern has been produced with the initial function call RecursivePattern(8,1) It prototype should be … | |
Re: [QUOTE]Try this one[/QUOTE] [CODE]#include<iostream.h> #include<conio.h> int find(int *a,int start,int end) { if(start<end) { if(a[start]<a[end]) { cout<<"1st Arrys condition"<<a[start]<<" "<<a[end]<<endl; return find(a,start+1,end); } else cout<<"2nd Arrys condition"<<a[start]<<" "<<a[end]<<endl; return find(a,start,end-1); } cout<<"Last= "<<a[end]<<endl; } void main() { clrscr(); const int size=8; int arr[size]={7,6,13,12,2,9,5,99}; for(int i=0;i<size;i++) { cout<<arr[i]<<" "; } cout<<endl; find(arr,0,size-1); … | |
Re: [QUOTE]Try It, I think it will solve your problem[/QUOTE] [CODE]#include<iostream.h> #include<conio.h> int find(int *a,int start,int end) { if(start<end) { if(a[start]<a[end]) { cout<<"1st Arrys condition"<<a[start]<<" "<<a[end]<<endl; return find(a,start+1,end); } else cout<<"2nd Arrys condition"<<a[start]<<" "<<a[end]<<endl; return find(a,start,end-1); } cout<<"Last= "<<a[end]<<endl; } void main() { clrscr(); const int size=8; int arr[size]={7,6,13,12,2,9,5,99}; for(int i=0;i<size;i++) … |
The End.