View Code of Problem 22

#include<stdio.h>
#include<string.h>
int main() {
	char a[1000],b[1000];
	int i,j,x[26];
	while(gets(a)!=NULL&&gets(b)!=NULL){
		for(i=0;i<26;i++){
			x[i]=0;
		}
		for(i=0;i<strlen(a);i++){
			for(j=0;j<strlen(b);j++){
				if(a[i]==b[j]){
					x[b[j]-'a']++;
					b[j]=' ';
					break;
				}
			}
		}

		for(i=0;i<26;i++){
			if(x[i]!=0){
				for(j=0;j<x[i];j++){
					printf("%c",'a'+i);
				}
			}
		}
		printf("\n");	
	}
	 
	return 0;
}

Double click to view unformatted code.


Back to problem 22