#include<bits/stdc++.h> using namespace std; int main (){ char s1[1010]; while(~scanf("%s", s1)){ char s2[1010], str[1010]; scanf("%s", s2); int cnt = 0; for(int i = 0;i < strlen(s1);i++){ for(int j = 0;j < strlen(s2);j++){ if(s1[i]==s2[j]){ str[cnt++] = s1[i]; s2[i] = '#'; break; } } } str[cnt] = '\0'; sort(str, str+cnt); printf("%s\n", str); } return 0; } |
Double click to view unformatted code.