View Code of Problem 22

#include <iostream>
#include <cstring>
using namespace std;
int a[26];
int main(){
	string s1,s2;
	while(cin>>s1>>s2){
		for(int i=0;i<s1.length();i++){
			char c=s1[i];
			for(int j=0;j<s2.length();j++){
				if(c==s2[j]){
					a[c-'a']=1;
					break;
				}
			}
		}
		for(int i=0;i<26;i++){
			if(a[i]){
				char c='a'+i;
				cout<<c;
			}
		}
		cout<<endl;
		memset(a,0,sizeof(a));
	}
	return 0;
}

Double click to view unformatted code.


Back to problem 22