#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <string.h>
using namespace std;
char v[21];
char c[500];
bool map_[26][26];
int main()
{
int t=0;
while(gets(v))
{
if(t) printf("\n");
memset(map_,0,sizeof(map_));
remove(v,&v[sizeof(v)],' ');
int len=strlen(v);
sort(v,v+len);
gets(c);
remove(c,&c[sizeof(c)],' ');
int len1=strlen(c);
for(int i=0; i<len1; i+=2)
map_[c[i]-'a'][c[i+1]-'a']=1;
do
{
bool flag=true;
for(int i=0; i<len; i++)
for(int j=i+1; j<len; j++)
if(map_[v[j]-'a'][v[i]-'a'])
flag=false;
if(flag) printf("%s\n",v);
}
while(next_permutation(v,&v[len]));
t++;
}
return 0;
}
#include <iostream>
#include <algorithm>
#include <string.h>
using namespace std;
int main()
{
string s="1122234225";
remove(s.begin(),s.end(),'2');
cout<<s;
return 0;
}
#include <iostream>
#include <algorithm>
#include <string.h>
using namespace std;
int main()
{
string s="1122234225";
s.erase(remove(s.begin(),s.end(),'2'),s.end());
cout<<s;
return 0;
}
输出:11345