题解 | #HJ102字符统计#

字符统计

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

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

int main() {
    char str[1000]={0};
    int a[255]={0};
    scanf("%[^\n]\n",str);
    for(int i=0;i<strlen(str);i++)
    {
        a[str[i]]++;
    }
    int maxcount=a[0];
    for(int i=0;i<255;i++)
    {
        if(a[i]>maxcount)
        {
            maxcount = a[i];
        }
    }
    while(maxcount)
    {
    for(int i=0;i<255;i++)
    {
        if(a[i]==maxcount){
            printf("%c",(char)(i));
        }  
    }
    maxcount--;
    }
   // printf("%d",maxcount);
    
    return 0;
}

全部评论

相关推荐

敢逐云霄志:你打招呼语怎么能这么长,hr都没看下去的欲望,简明扼要说重点,就读于某某学校某某专业,26届应届毕业生,学信网可查,先后在某某公司实习过(如有),然后做过什么项目,想找一份什么样的工作,可实习几个月以上,期待您的回复。
点赞 评论 收藏
分享
10-14 21:00
门头沟学院 Java
吃花椒的狸猫:这个人说的倒是实话,特别是小公司,一个实习生哪里来的那么多要求
点赞 评论 收藏
分享
评论
1
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务