//Divide and conquer recursion, find the maximum value of the array element, the minimum value/*** Save the resulting maximum, minimum value *@authorAdministrator **/ Public classValues {Private intMax; Private intmin; PublicValues (intMaxintmin) { This. max=Max; This. min=min; } Public intGetmax () {returnMax; } Public voidSetmax (intmax) { This. Max =Max; } Public intgetmin () {returnmin; } Public voidSetmin (intmin) { This. Min =min; }}/*** Divide and conquer recursively find the maximum number of elements in an array, the minimum number *@authorAdministrator **/ Public classMinmax { Public voidMin_max (intA[],intSinte,values Values) {Values lValues=NewValues (0,0); Values rValues=NewValues (0,0); if(e==s+1| | e==1) { if(a[s]>=A[e]) {Values.setmax (a[s]); Values.setmin (A[e]); } Else{Values.setmax (a[e]); Values.setmin (A[s]); } return; } intMid= (e+s)/2; Min_max (A,mid+1, e,lvalues); Min_max (a,s,mid,rvalues); Values.setmax (Lvalues.getmax ()>rvalues.getmax ()?Lvalues.getmax (): Rvalues.getmax ()); Values.setmin (Lvalues.getmin ()<rvalues.getmin ()?lvalues.getmin (): Rvalues.getmin ()); }}/*** Divide and conquer recursively find the maximum number of elements in an array, the minimum number *@authorAdministrator **/ Public classMinmax { Public voidMin_max (intA[],intSinte,values Values) {Values lValues=NewValues (0,0); Values rValues=NewValues (0,0); if(e==s+1| | e==s) { if(a[s]>=A[e]) {Values.setmax (a[s]); Values.setmin (A[e]); } Else{Values.setmax (a[e]); Values.setmin (A[s]); } return; } intMid= (e+s)/2; Min_max (A,mid+1, e,lvalues); Min_max (a,s,mid,rvalues); Values.setmax (Lvalues.getmax ()>rvalues.getmax ()?Lvalues.getmax (): Rvalues.getmax ()); Values.setmin (Lvalues.getmin ()<rvalues.getmin ()?lvalues.getmin (): Rvalues.getmin ()); }}
Divide and conquer recursion: Find the maximum value of the array element, the minimum value