【十二题解】 | #名字的漂亮度#

名字的漂亮度

http://www.nowcoder.com/practice/02cb8d3597cf416d9f6ae1b9ddc4fde3

#include<stdio.h>

int main

int number;
scanf("%d\n", &number);
for(int i=0; i<number; i++){
    int hash[26]={0};
    char name;
    scanf("%c", &name);
    while(name != '\n')
    {
        if(name>='a')
        {
            hash[name-'a']++;
        }
        else
        {
            hash[name-'A']++;
        }
        scanf("%c", &name);
    }
    int scord = 26;
    int max = 0;
    int all =0;
    int ans = 0;
    int loc = 0;
    for(int i=0; i<26; i++)
    {
        if(hash[i] != 0)all++;
    }
    for(int i=0; i<all; i++)
    {
        for(int j=0; j<26; j++)
        {
            if(hash[j]>max){
                max = hash[j];
                loc = j;
            }
        }
        ans+=scord*max;
        max = 0;
        hash[loc] = 0;
        scord--;
    }
    printf("%d\n", ans);
}

}

全部评论

相关推荐

当初高考报计算机真是造大孽了啊!卷的飞起!哪都是计算机的人,考研,考公,找工作全他奶的计算机的人,太难了。国企也是。关键一届比一届卷,造大孽了!
_Lyrics_:因为计算机,没有体验到快乐的大学研究生时光,好不容易修完课程就要出去实习,看着别人专业可以一起搓麻将,游山玩水,而我却要自己一个人住在北上不到十平米的出租屋,每天两点一线
点赞 评论 收藏
分享
评论
5
2
分享

创作者周榜

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