Create a program that computes the number of occurrences of the different characters in each input line and prints to the output the character with the most occurrences. Only a single character needs to be printed. If more than one character satisfies the condition, then the one which occurred earlier must be printed.
The input consists of nonempty lines containing printable ASCII characters.
Output for Sample Input
Hints and Guide
Because the number of printable ASCII characters are limited, we can count them by using an integer array where each value of the array stores the number of occurrences of a particular character. ASCII characters are represented as numbers (ASCII codes) from 32 to 127. These numbers can be used as indexes of the array. Note that the array indexing starts with 0.
One possible solution is available in: main.c.
Acknowledgement This work was supported by the construction EFOP-3.4.3-16-2016-00021. The project was supported by the European Union, co-financed by the European Social Fund.
|University of Debrecen; Faculty of Informatics; v. 03/01/2019|