题解 | #字符统计#投机取巧了...

字符统计

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

#include <stdio.h>

#include <string.h>

#include <stdlib.h>

int main()

{

    int i,j,count=0;

    int  hash[128]={0};

    char str[1001];

    scanf("%s",str);

    for(i=0;i<strlen(str);i++)

    {

        hash[str[i]]++;

    }

    //printf("%d",hash['c']);

    for(i=1000;i>=1;i--)

    {

        for(j=0;j<128;j++)

        {

            if(i==hash[j])

            printf("%c",j);

        }

    }

    return 0;

}

全部评论

相关推荐

评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客企业服务