View Code of Problem 22

#include<bits/stdc++.h>
using namespace std;
int main(){
	char a[1010];
	char b[1010];
	while(scanf("%s%s",a,b)!=EOF){
		int aa[200] = { },bb[200] = { };
		for(int i = 0;i<strlen(a);i++)aa[a[i]]++;
		for(int i = 0;i<strlen(b);i++)bb[b[i]]++;	
		for(int i = 97;i<125;i++){
			if(aa[i]&&bb[i]){
				printf("%c",(char)i);
			}
			
		}
		cout<<endl;
		a[0] = '\0';
		b[0] = '\0';	 
	} 
	return 0;
}

Double click to view unformatted code.


Back to problem 22