#include <stdio.h> #include <string.h> int main(){ char a[1000],b[1000],c[1000]; while(gets(a)){ gets(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+1;j<k;j++) if(c[i]>c[j]){ temp=c[i]; c[i]=c[j]; c[j]=temp; } printf("%c",c[i]); } printf("\n"); } } |
Double click to view unformatted code.