View Code of Problem 22

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

Double click to view unformatted code.


Back to problem 22