View Code of Problem 22

#include<iostream>
#include<algorithm>
#include<string.h>
using namespace std;
int main()
{
      char a[1000],b[1000],c[125];
      for(int t=97;t<123;t++)
         c[t]='*';
      while(cin>>a>>b)
      {  for(int t=97;t<123;t++)
         c[t]='*';
      	int alen=strlen(a),blen=strlen(b);
      	for(int i=0;i<alen;i++)
      	{
      		for(int j=0;j<blen;j++)
      		{
      			if(a[i]==b[j]) 
      			{
				  c[a[i]]=a[i];				  
				  }
			  }
		  }
		 for(int k=97;k<123;k++)
	     {
		  	  if(c[k]!='*')
		      cout<<c[k];
		  }
        
	  }	
}

Double click to view unformatted code.


Back to problem 22