View Code of Problem 22

#include<stdio.h> 
#include<string.h>
#include<math.h>
#include<ctype.h>
#include<stdlib.h>

int main(){ 
    int i,j;
    char s1[1001],s2[1001];
    while(~scanf("%s",s1)){
    	scanf("%s",s2);
    	int a[27]={0},b[27]={0};
    	int len1=strlen(s1);
    	int len2=strlen(s2);
    	for(i=0;i<len1;i++){
    		a[s1[i]-97]++;
		}
		
    	for(i=0;i<len2;i++){
    		b[s2[i]-97]++;
		}
		for(i=0;i<26;i++){
		while(a[i]>0&&b[i]>0){
			printf("%c",i+97);
            a[i]--;
            b[i]--;
		}
	}
	printf("\n");
	}
	
    return 0; 
     
}

Double click to view unformatted code.


Back to problem 22