今天來解YKL15(UVA10252):Common Permutation
找出兩個字串相同的char
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
int main(){
string a,b;
while(getline(cin,a) && getline(cin,b)){
if(a.empty() && b.empty()){
cout << endl;
continue;
}
vector<string> str;
for(int i=0;i<=a.size();i++){
for(int j=0;j<=b.size();j++){
if(a[i]==b[j]){
str.push_back(string(1,a[i]));
}
}
}
sort(str.begin(),str.end());
auto it = unique(str.begin(),str.end());
str.erase(it,str.end());
for(auto& results : str){
cout << results;
}
cout << endl;
}
return 0;
}