#include
#include
#include
using namespace std;
/*
功能:字符串处理
输入:两个字符串,需要异常处理
输出:合并处理后的字符串,具体要求参考文档
返回:无
*/
/* 方法一:非查表法
// 化为16进制数,位反转,转换为字符.不在范围内的字符,原样输出
char dochange(char ch)
{
char temp = ch;
int num = -1;
if(ch >= '0' && ch <= '9')
num = ch - '0';
else if( (ch >= 'a' && ch <= 'f') || (ch >= 'A' && ch <= 'F'))
num = tolower(ch) - 'a' + 10;
if(num != -1)
{
int bit[4]; // 16以内,4位
for(int i = 0; i < 4; i++)
{
bit[i] = num%2; // 从下标0开始存,已经反转了
num /= 2;
}
num = bit[0]*8 + bit[1]*4 + bit[2]*2 + bit[3]*1; // 这个数的范围是在0-16之间,用16进制表示它
if(num <= 9 && num >= 0)
temp = num + '0';
else if (num >= 10 && num <= 16)
temp = 'A' + num - 10;
}
return temp;
}
*/
// 方法2
// 化为16进制数,位反转,转换为字符, 不在范围的字符不需要处理,保持原样
char dochange(char ch)
{
char temp = ch;
switch(ch)
{
case '0':
temp = '0';
break;
case '1':
temp = '8';
break;
case '2':
temp = '4';
break;
case '3':
temp = 'C';
break;
case '4':
temp = '2';
break;
case '5':
temp = 'A';
break;
case '6':
temp = '6';
break;
case '7':
temp = 'E';
break;
case '8':
temp = '1';
break;
case '9':
temp = '9';
break;
case 'a':
case 'A':
temp = '5';
break;
case 'b':
case 'B':
temp = 'D';
break;
case 'c':
case 'C':
temp = '3';
break;
case 'd':
case 'D':
temp = 'B';
break;
case 'e':
case 'E':
temp = '7';
break;
case 'f':
case 'F':
temp = 'F';
break;
default:
break;
}
return temp;
}
void ProcessString(string str1,string str2,string & strOutput)
{
// 合并排序
strOutput = str1 + str2;
str1 = "";
str2 = "";
int totsize = strOutput.size();
for(int i = 0; i < totsize; i++)
{
if(i%2 == 0)
str1 += strOutput[i];
else
str2 += strOutput[i];
}
sort(str1.begin(),str1.end());
sort(str2.begin(),str2.end());
int i1 = 0, i2 = 0;
for(int i = 0; i < totsize; i++)
{
if(i%2 == 0)
{
strOutput[i] = str1[i1];
i1++;
}
else
{
strOutput[i] = str2[i2];
i2++;
}
}
// 转换为相应的大写字母
for(int i = 0; i < totsize; i++)
{
strOutput[i] = dochange(strOutput[i]);
}
}
int main()
{
string s1;
string s2;
while(cin >> s1 >> s2)
{
string strOutput = "";
ProcessString(s1,s2,strOutput);
cout << strOutput << endl;
}
}