View Code of Problem 22

#include<iostream>
#include<cstdio>

using namespace std;

int main()
{
	string a;
	string b;
	while(cin >> a >> b)
	{
		int n[26]={0};
		for(int i = 0; i < a.length(); i++)
		{
			int pos = -1;
			pos = b.find(a[i]);
			if(pos != -1)
				n[a[i]-'a'] = 1;
		}
		for(int i = 0; i < 26; i++)
			if(n[i] != 0)
			{
				cout << (char)(i + 'a');
			}
		cout << endl;
	}
	return 0;
}

Double click to view unformatted code.


Back to problem 22