View Code of Problem 22

#include<iostream>
#include<map>
using namespace std;
int main(){

	string str1;
	string str2;
	int res[26]={0};
	while(cin>>str1>>str2){
		map<char,int> mp;
		
		for(int i=0;i<str1.length();i++){
			mp[str1[i]]++;
			res[str1[i]-'a']=1;
		}
		
		
		
		for(int j=0;j<str2.length();j++){
			
			if(res[str2[j]-'a']==1){
				mp[str2[j]]--;
				res[str2[j]-'a']=0;
			}
				
			
		}
		
	
		for(map<char,int>::iterator it=mp.begin();it!=mp.end();it++){
			if(it->second==0){
			 cout<<it->first; 
		}
	}
		cout<<endl;
}

}

 

Double click to view unformatted code.


Back to problem 22