-
Notifications
You must be signed in to change notification settings - Fork 0
/
10252.cpp
34 lines (30 loc) · 902 Bytes
/
10252.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
#include <cstdio>
#include <cstring>
using namespace std;
int main(void)
{
int i, index, cnt[2][26];
char arr[10000];
while (gets(arr) != NULL) {
for (i = 0; i < 26; ++i)
cnt[0][i] = 0;
for (i = 0; i < strlen(arr); ++i) {
index = (int)(arr[i] - 'a');
if (-1 < index && index < 26) cnt[0][index]++;
}
gets(arr);
for (i = 0; i < 26; ++i)
cnt[1][i] = 0;
for (i = 0; i < strlen(arr); ++i) {
index = (int)(arr[i] - 'a');
if (-1 < index && index < 26) cnt[1][index]++;
}
for (i = 0; i < 26; ++i)
cnt[0][i] = cnt[0][i] < cnt[1][i] ? cnt[0][i] : cnt[1][i];
for (index = 0; index < 26; ++index)
for (i = 0; i < cnt[0][index]; ++i)
printf("%c", (char)(index + 'a'));
printf("\n");
}
return 0;
}