View Code of Problem 22

#include<bits/stdc++.h>
using namespace std;
int main()
{
	char a[1000],b[1000],c[1000];
	while(cin.getline(a,1000))
	{
		cin.getline(b,1000);
		int k=0;
	for(int i=0;i<strlen(a);i++)
	{
	for(int j=0;j<strlen(b);j++)
	{
		if(a[i]==b[j])
		{	
		c[k++]=a[i];
		b[j]='#';
		break;
		}
	}
	}
	sort(c,c+k);
   for(int i=0;i<k;i++)
   {
	cout<<c[i];
    }
    cout<<endl;
	}	
   return 0;
 } 

Double click to view unformatted code.


Back to problem 22