PAT 1042. Character Statistics (20)

Source: Internet
Author: User

Write a program to find the most frequent English letter in a given text.

Input format:

The input gives a string with a length of not more than 1000 in a row. The string consists of any visible characters and spaces in the ASCII code table, containing at least 1 English letters, ending with a carriage return (carriage return does not count).

Output format:

Outputs the most frequently occurring English letter in a row and its occurrences, separated by a space. If there is a tie, the letter with the smallest alphabetical order is output. Statistics are case insensitive and output lowercase letters.

Input Sample:

This was a simple TEST.  There is numbers and other symbols 1&2&3 .....

Sample output:

E 7
1#include <stdio.h>2#include <string.h>3#include <stdlib.h>4#include <ctype.h>5#include <math.h>6 7 intMain () {8     inta[ +]={0};9     Charb[1010];Ten gets (b); One     intLenB =strlen (b); A     CharC; -      for(intI=0; i<lenb;i++){ -B[i] =ToLower (B[i]); the     } -      for(intI=0; i<lenb;i++){ -         if(b[i]<='Z'&&b[i]>='A'|| b[i]<='Z'&&b[i]>='a') -a[b[i]]++; +     } -     intMax =0; +      for(intI=0;i< +; i++){ A         if(a[i]>max) { atc =i; -Max =A[i]; -         } -         Else if(a[i]==max) { -             if(i<c) { -c =i; inMax =A[i]; -             } to                  +         } -     }  theprintf"%c%d", C,max);  *}

PAT 1042. Character Statistics (20)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.