#include <stdio.h> #include <string.h> int main() { char a[1000]={0},b[1000]={0}; while (gets(a)!=NULL,gets(b)!=NULL) { char same[1000]={0}; int i=0,j,z=0; char tmp; while (a[i++]) { j=0; while (b[j++]) { if (a[i-1]==b[j-1]) { b[j-1]='1'; same[z]=a[i-1]; z++; break; } } } for(i=0;i<z;i++) { int min=i; for(j=0;j<z;j++) { if(same[j]>same[min]) min=j; } tmp=same[i]; same[i]=same[min]; same[min]=tmp; } puts(same); } return 0; } |
Double click to view unformatted code.