#include <bits/stdc++.h> #include<cstring> using namespace std; int main() { char a[1000]; char b[1000]; while(gets(a)!=NULL&&gets(b)!=NULL){ int k[26]={0}; int x=strlen(a); int x1=strlen(b); for(int i=0;i<x;i++){ for(int j=0;j<x1;j++){ if(a[i]==b[j]){ k[a[i]-'a']++; b[j]='0'; break; } } } for(int j=0;j<26;j++) { for(int q=k[j];q>0;q--){ printf("%c",j+'a'); } } cout<<endl; } return 0; } |
Double click to view unformatted code.