Other people's Reference
45967535
Your own algorithm.
Include
using namespace Std;
void Mid (int a[],int aleft,int aright,int b[],int bleft,int Bright)
{
Double mid;
int n=aright-aleft+1;
int k1= (aleft+aright)/2;
int k2= (bleft+bright)/2;
if (aright-aleft==1&&bright-bleft==1)
{
cout<< "mid=" << (Max (A[aleft], B[bleft]) + min (A[aright], b[bright])/2.0<<endl; return;} if ((aleft==aright) && (bleft==bright)) {mid= (A[aleft]+b[bleft])/2.0; cout<< "Mid=" <<mid<<endl; Return }else{if (A[k1]==b[k2]) {MID=A[K1]; cout<< "Mid=" <<mid<<endl; } if (A[k1]<b[k2]) {Mid (A,K1,ARIGHT,B,BLEFT,K2); cout<< "Mid1 (A,K1,N-1,B,0,K2)" << "" <<k1<< "<<aright<<" "<<" "<< bleft<< "" <<k2<<endl; } if (A[k1]>b[k2]) {Mid (a,aleft,k1,b,k2,bright); cout<< "Mid2 (a,0,k1,b,k2,n-1)" << "" <<aleft<< "<<k1-1<<" "<<" "<< k2<< "" <<bright<<endl; }}
}
int main ()
{
int A[]={1, 12, 15, 26, 38};
int b[]={13, 14, 40, 42, 45};
Mid (a,0,4,b,0,4);
System ("pause");
}
Divide and conquer the method to seek the median number