Input:
有多组测试样例,输入直到文件末尾。
每组样例占两行,每组第一行为龙a的名字,第二行为龙b的名字。
Output:
对每组样例输出一行,输出内容为龙a与龙b名字相同的字母。
#include <iostream>
#include "set"
#include "string"
using namespace std;
/**
* kkmd66 四刷
* @return
*/
int main() {
//两个不同的名字
string name_1, name_2;
while (getline(cin, name_1) && getline(cin, name_2)) {
//依次遍历比对,相同的则把name_2对应的字符设置为'#',并将对应的字符存储
multiset<char> multiset;
for (int i = 0; i < name_1.size(); ++i) {
for (int j = 0; j < name_2.size(); ++j) {
if (name_1[i] == name_2[j]) {
name_2[j] = '#';
multiset.insert(name_1[i]);
break;
}
}
}
//输出
for (auto i: multiset) {
cout << i;
}
cout << endl;
}
return 0;
}