文章

13

粉丝

0

获赞

16

访问

1.7k

头像
字母统计 题解:
P1292 上海交通大学机试题
发布于2026年1月31日 02:30
阅读数 179

#include<bits/stdc++.h>
using namespace std;

int main(){
    char s[1001];
    while(fgets(s,sizeof(s),stdin) != NULL){
        int count[26] = {0};
        for(int i = 0; s[i] != '\0'; i++){
            if(isupper(s[i])){
                count[s[i] - 'A']++;
            }
        }
        for(int i = 0; i < 26; i++){
            printf("%c:%d\n",'A' + i,count[i]);
        }
    }
     return 0;
}

登录查看完整内容


登录后发布评论

暂无评论,来抢沙发