problem in c++ code
helo guys...I have a problem in following c++ code...I want to find largest and smallest element in an array..using recurssion..please help me
#include#include int max1,min1; void maxmin(int a[],int,int,int*,int*); int main() { int i,*a,n,max,min; cout<<"Enter the no of elements"< >n; a=new int[n]; cout<<"Enter elements"< >a[i]; } maxmin(a,0,n-1,&max,&min); cout<<"Maximum element"< a[finish]) { *max=a[start]; *min=a[finish]; } else { *max=a[finish]; *min=a[start]; } } else mid=(start+finish)/2; maxmin(a,start,mid,*&max,*&min); maxmin(a,mid+1,finish,&max1,&min1); if(max1>*max) { *max=max1; } if(*min>min1) { *min=min1; } }
Replies
-
Manish GoyalHello ceans I have solved this problem.there was small mistake..I hope most of you had tried this ..this code is for those who are unable to solve this..
#include
#include int max1,min1; void maxmin(int a[],int,int,int*,int*); int main() { int i,*a,n,max,min; cout<<"Enter the no of elements"< >n; a=new int[n]; cout<<"Enter elements"< >a[i]; } maxmin(a,0,n-1,&max,&min); cout<<"Maximum element"< a[finish]) { *max=a[start]; *min=a[finish]; } else { *max=a[finish]; *min=a[start]; } } else { mid=(start+finish)/2; maxmin(a,start,mid,*&max,*&min); maxmin(a,mid+1,finish,&max1,&min1); if(max1>*max) { *max=max1; } if(*min>min1) { *min=min1; } } }
You are reading an archived discussion.
Related Posts
find the volume of the solid cut from the thick walled cylinder 1<=x^2+y^2<=2 by the conesz=+-(x^2+y^2)^(1/2).
using dz dr dtheta
Hi,
i am student of 3rd-year computer science.I am interested in networking.
I have done certifications in J2SE and CCNA.
I want to further enhance my skills in this field.Please...
I guess in dis new technology a touch pad gear shift should be give a try .
The car should be setup wit a small microprocesser chip which tels the...
hi call me torque.
i am 18(almost 19) and i am graduating high school in december. curently i posses nearly no experiance in engineering. my only knowlege of engineering is...
hello friends ,
I have a labtop which is vista based . visual c++ is not compatible with it . Is this problem can be sort out..