#include <iostream>
using namespace std;
class Test
{
public:
Test();
void InterFace();
void ShowDef();
void ShowSame();
void GetArrayA();
void GetArrayB();
protected:
private:
int m_nArray_1[20], m_nArray_2[20];
int m_nDef, m_nSame;
bool m_bRetCode;
};
Test::Test()
{
m_nDef = 0;
m_nSame = 0;
m_bRetCode = false;
}
void Test::GetArrayA()
{
int i, j, k, l;
cin >> j;
for(i = 0; i < j; i++)
{
cin >> k;
for (l = 0; l <= i; l++) //排除相同的
{
if (k == m_nArray_1[l])
{
m_bRetCode = true;
break;
}
}
if (!m_bRetCode)
{
m_nArray_1[m_nDef++] = k; //得到 A 中的不同元素
}
m_bRetCode = false;
}
InterFace();
}
void Test::GetArrayB()
{
int i, j, k, l;
cin >> j;
for(i = 0; i < j; i++)
{
cin >> k;
for (l = 0; l < m_nDef; l++)
{
if (k == m_nArray_1[l]) //得到交集
{
m_nArray_2[m_nSame++] = k;
m_bRetCode = true;
break;
}
}
if (!m_bRetCode) //得到并集
{
m_nArray_1[m_nDef++] = k;
}
m_bRetCode = false;
}
InterFace();
}
void Test::ShowSame()
{
for (int i = 0; i < m_nDef; i++)
{
cout << m_nArray_1[i] << endl;
}
InterFace();
}
void Test::ShowDef()
{
for (int j = 0; j < m_nSame; j++)
{
cout << m_nArray_2[j] << endl;
}
InterFace();
}
void Test::InterFace()
{
char szWord;
cin >> szWord;
switch (szWord)
{
case 'A'|'a':
GetArrayA();
break;
case 'B'|'b':
GetArrayB();
break;
case 'E'|'e':
exit(1);
break;
case 'U'|'u':
ShowSame();
break;
case 'I'|'i':
ShowDef();
break;
default:
break;
}
}
int main()
{
Test t1;
while (1)
{
t1.InterFace();
}
return 0;
}