#include<stdio.h> #include<string.h> int main() { char a[1000]; char b[1000]; char c[1000]; while(gets(a)!=NULL) { int l1,l2; gets(b); l1=strlen(a); l2=strlen(b); int i,j,k=0; for(i=0;i<l1;i++) { for(j=0;j<l2;j++) { if(a[i]==b[j]) { c[k]=a[i]; k++; b[j]='*'; break; } } } char temp; 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"); } return 0; } |
Double click to view unformatted code.