实现删除字符串中出现次数最少的字符,若多个字符出现次数一样,则都删除。输出删除这些单词后的字符串,字符串中其它字符保持原来的顺序。
void HWoj(){
string test = "aaaabbbcc",Outstr="";
int book[256] = { 0 };
int len = test.length(), mined=1;
for (int i = 0; i < len; ++i){
++book[test[i]];
}
mined = book[test[0]];
for (int i = 0; i < len; ++i){
if (book[test[i]] <= mined){
mined = book[test[i]];
}
}
for (int i = 0; i < len; ++i){
if (book[test[i]] > mined){ Outstr.push_back(test[i]); }
}
cout << Outstr << endl;
}