hdu1219 AC Me

来源:互联网 发布:淘宝网店助理 编辑:程序博客网 时间:2024/06/08 08:58
#include <stdio.h>
#include <string.h>
#include <ctype.h>


int main()
{
    int a[30];
    char s[100005];
    char let[27] = "abcdefghijklmnopqrstuvwxyz";
    while(gets(s))
    {
        memset(a, 0, sizeof(a));
        int len = strlen(s);
        for(int i = 0; i < len; i++)
            if(isalpha(s[i])) a[s[i]-'a']++;
        for(int i = 0; i < 26; i++)
            printf("%c:%d\n",let[i],a[i]);
        printf("\n");
    }

}

心得:水题,不过学习了输出字母前用char先打表,想必是极好的。

0 0
原创粉丝点击