字母统计 题解:
#include<bits/stdc++.h>
using namespace std;
int main(){
string str;
while(cin >> str){
int times[26] = {0};
for(char c:str){
if(c >= 'A' && c <= 'Z')
times[c - 'A' + 0]++;
}
for(int i=0;i<26;i++){
char k = i + 'A';
cout << k << ":" << times[i] << endl;
}
}
return 0;
}
登录后发布评论
暂无评论,来抢沙发