简单题
View Code
#include#include #include #include using namespace std; #define maxl 1005 #define maxn 30 int f[maxn], g[maxn]; char a[maxl], b[maxl]; void make(char *st, int f[]) { int len = strlen(st); for (int i = 0; i < len; i++) f[st[i] - 'a']++; } void work() { for (int i = 0; i < 26; i++) { int x = min(f[i], g[i]); for (int j = 0; j < x; j++) putchar(i + 'a'); } putchar('\n'); } int main() { //freopen("t.txt", "r", stdin); while (gets(a)) { gets(b); memset(f, 0, sizeof(f)); memset(g, 0, sizeof(g)); make(a, f); make(b, g); work(); } return 0; }