#include <iostream>
#include <string>
using namespace std;
int main(){
string str = "";
//char str[200];
cin >> str;
//cin.getline(str,200);
int cnt[256]={};
for(int i = 0; i < str.size(); i++)
//for(int i =0; i < strlen(str); i++)
{
cnt[(int)str[i]]++;
}
for(int i = 0; i < 256; i++){
if(cnt[i] != 0){
cout << (char)i << ":" << cnt[i]<< endl;
}
}
return 0;
}
PS:使用注释部分可以读取空格和标点符号字符。
转载于:https://www.cnblogs.com/Podevor/archive/2011/06/19/2788198.html
最后
以上就是沉默树叶最近收集整理的关于C++字符统计的全部内容,更多相关C++字符统计内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复