#include <stdio.h> #include <string.h> int main(){ char a[1000],b[1000],c[1000]; while(~scanf("%s %s",a,b)){ int i,j,k=0,temp; for(i=0;i<strlen(a);i++) for(j=0;j<strlen(b);j++){ if(a[i]==b[j]){ c[k++]=a[i]; b[i]='*'; break; } } for(i=0;i<k;i++) for(j=i;j<k;j++) if(c[i]>c[j]){ temp=c[i]; c[i]=c[j]; c[j]=temp; } for(i=0;i<k-1;i++) printf("%c",c[i]); printf("%c\n",c[k-1]); } } |
Double click to view unformatted code.