View Code of Problem 22

#include<iostream>
#include<algorithm>

using namespace std;


int main(){
	string s1;
	string s2;
	while(getline(cin,s1),getline(cin,s2)){
		char c[1000];
		int count=0;
		for(int i=0;i<s1.length();++i){
			for(int j=0;j<s2.length();++j){
				if(s1[i]==s2[j]){
					c[count++]=s1[i];
					break;
				}
			}
		}
		sort(c,c+count);
		for(int i=0;i<count;++i){
			cout<<c[i];
		}
		cout<<endl;
	}
	return 0;
} 

Double click to view unformatted code.


Back to problem 22