View Code of Problem 22

#include<iostream>
#include<algorithm>
#include<string>
#include<cstring>
using namespace std;
int main(){
	string a,b;
	char c[200];
	int k; 
	while(cin>>a>>b){
		k=0;
		for(int i=0;i<a.length();i++)
		for(int j=0;j<b.length();j++){
			if(a[i]==b[j]){
				c[k++]=a[i];
				b[j]='*';
		}
		}
		sort(c,c+k);
		for(int i=0;i<k;i++){
			if(c[i]!=c[i+1]) {
			if(i!=k-1){
				cout<<c[i]; 
			}else{
				cout<<c[i]<<endl; 
			}
				
				
				
			}
			
		}
	} 
	
	
	return 0;
}

Double click to view unformatted code.


Back to problem 22