//2016.1 输入一行字符串,输出出现频率最高的数字和字母,字母无视大小写。
#include<iostream>
#include<stdio.h>
#include<ctype.h>
#include<string.h>
using namespace std;

int main()
{
    int a[256]={0};
    char b[20];//字符串和相应的字符频率统计数组。
    cin>>b;
    int i;
    for(i=0;i<20;i++)//各个字符频率统计。
    {
        if(isalpha(b[i])) a[tolower(b[i])]++; //关键所在,直接用字母的值所对应的数组
                                                      //记住频率。

    }

    int maxzimu='a';
    int maxshuzi='z';
    for(i='a';i<'z';i++) //找出字母出现频率最大。
    {
        if(a[maxzimu]<a[i]) maxzimu=i;




    }


    printf("%c  %d",maxzimu,a[maxzimu]);
    cout<<endl<<(char)(maxzimu)<<"  "<<a[maxzimu];






    return 0;
}

2016.1 输入一行字符串,输出频率和相应字母,字母无视大小写。

相关文章:

  • 2022-12-23
  • 2022-01-16
  • 2022-12-23
  • 2021-07-29
  • 2022-01-02
  • 2022-03-08
  • 2022-12-23
  • 2021-10-16
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-08-04
  • 2021-08-16
  • 2021-12-17
  • 2022-12-23
相关资源
相似解决方案