close
#include <algorithm>
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include <iostream>
#include <stdlib.h>
struct T
{
    char ch;
    int Fre=0;
};
bool operator < (const T &lhs,const T &rhs)
{
    return lhs.Fre > rhs.Fre;
}
int main()
{
    T record[26];
    int count=0;
    int n;
    std::string str;
    scanf("%d",&n);
//    getchar();
//    getchar();
    getline(std::cin,str);
    while(n--)
    {
        //printf("PIG!\n");
        getline(std::cin,str);
        for(int i=0;i<str.length();i++)
        {
            if(isalpha(str[i]))
            {
                if(! record[toupper(str[i])-'A'].Fre)
                {
                    record[toupper(str[i])-'A'].ch = toupper(str[i]);
                }
                record[toupper(str[i])-'A'].Fre++;
            }
        }
    }
    std::stable_sort(record,record+26);
    for(int i=0;i<26;i++)
    {
        if(record[i].Fre)
        printf("%c %d\n",record[i].ch,record[i].Fre);

    }
    return 0;
}
#英文字元處理#sort
arrow
arrow
    文章標籤
    sort
    全站熱搜
    創作者介紹
    創作者 Nate_Tang 的頭像
    Nate_Tang

    Nate - life is tough,but I'm tougher

    Nate_Tang 發表在 痞客邦 留言(0) 人氣()