题解 | #字母统计#

字母统计

https://www.nowcoder.com/practice/de7bf0945c1c4bd1aa9d49573b831f3c

#include <stdio.h>
#define MAX 1000
int main() {
    char str[MAX]={0};
    char A[26]="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
    gets(str);
    int l=strlen(str);
    for(int i=0;i<26;++i){
        int cnt=0;
        for(int j=0;j<l;++j){
            if(A[i]==str[j]) cnt++;
        }
        printf("%c:%d\n",A[i],cnt);
    }
    return 0;
}

全部评论

相关推荐

评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客企业服务