499-What's The Frequency, kenth?

Source: Internet
Author: User

Include <stdio. h>

Main ()
{
Int I;
Char * suffix [] = {"st", "nd", "rd "};
Char * item [] = {"Unix", "cat", "sed", "awk", "grep", "ed", "vi "};
 
Printf ("In the beginning, there was nothing. \ n ");
For (I = 0; I <7; I ++)
Printf ("And on the % d % s day, God created % s. And it was good. \ n ",
I + 1, (I <3 )? Suffix [I]: "th", item [I]);
} But then God saw that vi led people into temptation. Instead of choosing the righteous ways of make, dbx, and RCS, people used long command lines, printf (), and tape backups.

So God decreed, 'I see that Engineers have thus defiled my vi. and so, I shall create emacs, an editormore powerful than words. further, for each instantiation vi hitherto, the Engineer responsible shalt extends mpenance. and lo, the Penance wilt be painful; there will be much wailing and gnushingof teeth. the Engineerwill read your lines of text. for each line of text, the Engineer must tell me which letters occur the most frequently.''

''I charge you all with My Golden Rule: 'ds DS shalt not let Friends use vi '.''


Input and Output
Each line of output shoshould contain a list of letters that all occured with the highest frequency in the corresponding input line, followed by the frequency.

The list of letters shoshould be an alphabetical list of upper case letters followed by an alphabeticallist of lower case letters.


Sample Input

When riding your bicycle backwards down a one-way street, if
Wheel falls of a canoe, how many ball bearings does it take to fill
Up a water buffalo?
Hello Howard.
Sample Output

E 6
Al 7
A 3
Hlo 2 [cpp]
# Include <stdio. h>
# Include <string. h>
Int max (int *)
{
Int I, max = 0;
For (I = 0; I <52; I ++)
If (a [I]> max) max = a [I];
Return max;
}
Int main (void)
{
Char a [100] = {0 };
 
While (gets ())! = NULL)
{
Int count [52] = {0}, I;
For (I = 0; I <strlen (a); I ++)
{
If (a [I] <= 'Z' & a [I]> = 'A ')
Count [a [I]-'A' + 26] ++;
Else if (a [I] <= 'Z' & a [I]> = 'A ')
Count [a [I]-'a'] ++;
}
For (I = 0; I <52; I ++)
If (count [I] = max (count ))
{
If (I <26)
Putchar (I + 'A ');
Else
Putchar (I + 'a'-26 );
}
Printf ("% d \ n", max (count ));
}
Return 0;
}

# Include <stdio. h>
# Include <string. h>
Int max (int *)
{
Int I, max = 0;
For (I = 0; I <52; I ++)
If (a [I]> max) max = a [I];
Return max;
}
Int main (void)
{
Char a [100] = {0 };

While (gets ())! = NULL)
{
Int count [52] = {0}, I;
For (I = 0; I <strlen (a); I ++)
{
If (a [I] <= 'Z' & a [I]> = 'A ')
Count [a [I]-'A' + 26] ++;
Else if (a [I] <= 'Z' & a [I]> = 'A ')
Count [a [I]-'a'] ++;
}
For (I = 0; I <52; I ++)
If (count [I] = max (count ))
{
If (I <26)
Putchar (I + 'A ');
Else
Putchar (I + 'a'-26 );
}
Printf ("% d \ n", max (count ));
}
Return 0;
}

 

Related Article

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: info-contact@alibabacloud.com 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.