#include<bits/stdc++.h> using namespace std; int main (){ char s1[1010]; while(gets(s1)){ char s2[1010], str[1010]; gets(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); // printf("%s\n", str); puts(str); } return 0; } |
Double click to view unformatted code.