1042 字符统计 (20分)

#include <string.h>
#include <iostream>
using namespace std;

int main()
{
    char str[1005];
    int big[27]={0};
    int max=0;
    char max_s;
    fgets(str,1005,stdin);
    for(int i=0;i<strlen(str);i++)
    {
        if(str[i]>='A'&&str[i]<='Z')
            big[str[i]-65]++;
        else if(str[i]>='a'&&str[i]<='z')
            big[str[i]-97]++;
    }
    for(int i=0;i<26;i++)
    {
        if(big[i]>max)
        {
            max=big[i];
            max_s=i+97;
        }
    }
    cout<<max_s<<" "<<max<<endl;
    
    return 0;
}
原文地址:https://www.cnblogs.com/QRain/p/12252556.html