View Code of Problem 22

#include <stdio.h>
#include <string.h>
int main(){
	char a[1001]={'\0'},b[1001]={'\0'};
	while(scanf("%s",a)!=EOF){
		int num[26]={0};
		scanf("%s",b);
		int i,j;
		for(i=0;i<strlen(a);i++){
			for(j=0;j<strlen(b);j++){
				if(a[i]==b[j]){
					num[a[i]-'a']++;
					b[j]=1;
					break;
				}
			}
		}
		for(i=0;i<26;i++){
			for(j=num[i];j>0;j--){
				printf("%c",i+'a');
			}
		}
		printf("\n");
	}
	return 0;
} 

Double click to view unformatted code.


Back to problem 22