
#include <algorithm>
#include <iostream>
#include <string>
#include <unordered_map>
using namespace std;
int main() {
string str;
cin >> str;
unordered_map<char, int> myMap;
int smallest = str.size() + 1;
for (auto &c : str) {
myMap[c]++;
}
for (auto iter = myMap.begin(); iter != myMap.end(); ++iter) {
smallest = min(smallest, iter->second);
}
for (auto &c : str) {
if (myMap[c] == smallest) {
continue;
}
cout << c;
}
return 0;
}
// 64 位输出请用 printf("%lld")
该C++程序读入一个字符串,利用unordered_map存储每个字符出现的次数,找到出现次数最少的值。然后遍历字符串,只打印出现次数不等于最小值的字符。
740

被折叠的 条评论
为什么被折叠?



