文章

36

粉丝

0

获赞

4

访问

10.3k

头像
字母统计 题解:
P1292 上海交通大学机试题
发布于2024年3月6日 11:50
阅读数 241

#include <stdio.h>
#include <stdbool.h>
#include <math.h>
#include <string.h>

int main(void) {
    char s[1000];
    char s1[]={'A','B','C','D','E','F','G','H','I','J','K','L','M','N',
        'O','P','Q','R','S','T','U','V','W','X','Y','Z'};
    while(gets(s)!=NULL){
        for(int i=0;i<strlen(s1);i++){
            int ans=0;
            for(int j=0;j<strlen(s);j++){
                if(s1[i]==s[j]) ans++;
            }
            printf("%c:%d\n",s1[i],ans);
        }
    }
    
    return 0;
}

 

登录查看完整内容


登录后发布评论

暂无评论,来抢沙发