UVa 10252 Common Permutation
水题一枚, 找出两串中相同的每一个字符, 按字典序排列输出即可
#include <iostream>
using namespace std;
#include <algorithm>
#include <stdio.h>
#include <string.h>
char a[1005];
char b[1005];
char c[1005];
int main()
{
while (gets(a) != NULL && gets(b) != NULL)
{
memset(c, 0, sizeof(c));
int t = 0;
for (int i = 0; i < strlen(a); i ++)
{
for (int j = 0; j < strlen(b); j ++)
{
if (a[i] == b[j])
{
c[t ++] = a[i];
b[j] = '*';
break;
}
}
}
c[t] = '\0';
sort(c, c + t);
printf("%s\n", c);
}
return 0;
}