c语言任意输入一个字符串,统计每个小写字母出现的次数并输出

c语言任意输入一个字符串,统计每个小写字母出现的次数并输出

第1个回答  2018-05-17
int *LetterCount(const char *s)
{
    int *num = (int*)malloc(sizeof(int)*26);
    char ch;
    
    memset(num, 0, sizeof(int)*26);   
    while( (ch=*s++) != '\0')
    {
        if( ch>='a' && ch<='z') 
            ++num[ch-'a'];
    }
    return num;
}

本回答被网友采纳
相似回答