// 中位数.cpp : 此文件包含 "main" 函数。程序执行将在此处开始并结束。
//
#include <iostream>
using namespace std;
int S1[] = {11,13,15,17,19};
int S2[] = {2,12,16,18,20};
void search(int a[],int b[],int n) {
int top1 = 0, top2 = 0, count = 0,flag=-1;
while (count <n-1 )
{
if (a[top1] <= b[top2])
{
//cout << a[top1] << "\n";
top1++;
flag = 0;
}
else
{
//cout << b[top2] << "\n";
top2++;
flag = 1;
}
count++;
}
if (flag == 1)
cout << b[top2];
else if (flag == 0)
cout << a[top1];
else if (a[0] <= b[0])
cout << a[0];
else
cout << b[0];
}
int main()
{
search(S1, S2, 5);
}