-
Notifications
You must be signed in to change notification settings - Fork 23
/
Copy path0030.cpp
44 lines (42 loc) · 1013 Bytes
/
0030.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
// 0030.字符串合并处理
#include <iostream>
#include <algorithm>
using namespace std;
int main()
{
string a, b, s;
string np = "0123456789ABCDEF";
char c;
char mp[16] = {'0','8','4','C','2','A','6','E','1','9','5','D','3','B','7','F'};
while(cin >> a >> b)
{
s = a+b;
a = "";
b = "";
for(int i = 0; i < s.size(); i++)
{
if(i%2 == 0) a += s[i];
else b += s[i];
}
sort(a.begin(), a.end());
sort(b.begin(), b.end());
s = "";
for(int i = 0; i < a.size(); i++)
{
s += a[i];
if(i < b.size()) s += b[i];
}
a = "";
for(int i = 0; i < s.size(); i++)
{
c = s[i];
if ((c <= 'f' && c >= 'a') || (c <= 'F' && c >= 'A')
|| (c <= '9' && c >= '0')) {
c = mp[np.find(toupper(c))];
}
a += c;
}
cout << a << endl;
}
return 0;
}