#include<bits/stdc++.h> using namespace std; int main (){ char s1[1010], s2[1010], str[1010]; while(cin >> s1 >> 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[j] = '#'; break; } } } str[cnt] = 0; sort(str, str+cnt); cout << str; } return 0; } |
Double click to view unformatted code.