View Code of Problem 22

// 111.cpp : 定义控制台应用程序的入口点。
//

#include<stdio.h>
#include<string.h>
int main()
{
	char a[1001]={0},b[1001]={0};
	int x[200]={0},y[200]={0},z[26]={0},i,j,k,Lenth1,Lenth2;
	while(gets(a)&&gets(b))
	{
		Lenth1=strlen(a);
		Lenth2=strlen(b);
 		for(i=0;i<Lenth1;i++)
			x[a[i]]++;
		for(i=0;i<Lenth2;i++)
			y[b[i]]++;
		for(i='a';i<='z';i++)
		{
			if(x[i]<y[i])
				z[i]=x[i];
			else
				z[i]=y[i];
			for(j=0;j<z[i];j++)
				printf("%c",i);
		}
		for(i='a';i<='z';i++)
			x[i]=y[i]=0;
		printf("\n");
	}
	return 0;
}

Double click to view unformatted code.


Back to problem 22