📌  相关文章
📜  列出字符串中出现的字符 c++ 代码示例

📅  最后修改于: 2022-03-11 14:44:55.479000             🧑  作者: Mango

代码示例1
int d[27]={0};
for (int i = 0; i < str.length(); i++)      //AABBCC
    d[str[i] - 'A']++;
for (int i = 0; i < str.length(); i++) 
    if (d[str[i] - 'A'] != 0) {
        cout << str[i] << " "<< d[str[i] - 'A'] << " "; //A 2 B 2 C 2 
}