View Code of Problem 22

#include<bits/stdc++.h>
using namespace std;
int main()
{
	char a[1005],b[1005];
	int i,j;
	while(gets(a))
	{
		gets(b);
		int s[26]={0};
		for(i=0;i<strlen(a);i++)
		{
			for(j=0;j<strlen(b);j++)
			{
			if(a[i]==b[j])
			{
				s[a[i]-'a']++;
				b[j]='0';
				break;
				}	
			}
		}
		for(i=0;i<26;i++)
		{
			while(s[i]!=0)
			{
				cout<<(char)(i+'a');
				s[i]--;
			}
		}
		cout<<endl;
	}
	return 0;
}

Double click to view unformatted code.


Back to problem 22