View Code of Problem 22

#include<stdio.h>
#include<string.h>
int main()
{
	char s1[1000],s2[1000];
	int i,t;
	int a[27];
	while(gets(s1)!=NULL)
	{
	//	getchar();
		for(i=1;i<27;i++)
			a[i]=0;
		for(i=0;i<strlen(s1);i++)
		{
			t=s1[i]-96;
			if(a[t]==0)
				a[t]=1;
		}
		gets(s2);
	//	getchar();
		for(i=0;i<strlen(s2);i++)
		{
			t=s2[i]-96;
			if(a[t]==1)
				a[t]=2;
		}
		
		for(i=1;i<27;i++)
		{
			if(a[i]==2)
				printf("%c",96+i);	
		}
		printf("\n");		
	}
		
	return 0;
}

Double click to view unformatted code.


Back to problem 22