#include <iostream>
// write your code here......
#include<map>
using namespace std;
#include<string>
int main() {
string str;
getline(cin,str);
// write your code here......
map<char, int>m;
int i = 0;
while (str[i] != '\0')
{
if (isalpha(str[i]))
{
m[str[i]]++;
i++;
}
else
{
i++;
}
}
for (auto i = m.begin(); i != m.end(); i++)
{
cout << i->first << ":" << i->second << endl;
}
return 0;
}
C++统计字符串中各字母字符对应的个数
最新推荐文章于 2023-12-17 21:37:53 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)