文章

34

粉丝

261

获赞

10

访问

11.0k

头像
字母统计 题解:用map比较简洁
fzh VIP
P1292 上海交通大学机试题
发布于2024年1月29日 14:10
阅读数 275

#include <bits/stdc++.h>
using namespace std;
int main()
{
string str;    
map<char,int>mp;
while(cin>>str)
{
 for(int i=0;i<str.length();i++)
     if(str[i]>='A'&&str[i]<='Z') mp[str[i]]++;
for(char i='A';i<='Z';i++)
      cout<<i<<":"<<mp[i]<<endl;
}}

登录查看完整内容


登录后发布评论

暂无评论,来抢沙发