Given a sequence of words, we wish to know:
Which is the average length of its words.
For every word with length or longer, which is the most frequent letter (the smallest in lexicographic order in case of ties).
To solve the second question, your program must implement the function
char most_frequent_letter(const string& s);
which returns the lowercase letter with most occurrences inside the word represented by s (and the smallest in lexicographic order when ties occur).
The input is formed by a natural followed by non-empty words. Each word is formed exclusively by lowercase letters.
Print the average length of the words in the input sequence with precision 2. Additionally print, for every word with length equal or longer to the average one, the lowercase letter with most occurrences inside the word (the smallest in lexicographic order when ties). Please, follow the output format given in the examples.
Recall that, in order to fix a decimal precision in the output channel, you need to use the following instructions
cout.setf(ios::fixed);
cout.precision(d);
You may find useful to define and use the constant @LENGTH_ALPHABET@,
const int LENGTH_ALPHABET = ’z’ - ’a’ + 1;
Input
5 this is the third control
Output
4.20 third: d control: o
Input
1 hello
Output
5.00 hello: l
Input
5 all bye one two rye
Output
3.00 all: l bye: b one: e two: o rye: e
Input
5 there are many programming paradigms
Output
6.40 programming: g paradigms: a