#C6954. Letter Frequency Counter
Letter Frequency Counter
Letter Frequency Counter
You are given a string consisting of lowercase letters. Your task is to count the frequency of each letter in the string and output the results. For each letter that appears in the input, output a line in the format letter: count
. The letters in the output must be sorted in alphabetical order.
For example, if the input is test
, the output should be:
e: 1 s: 1 t: 2
If the input string is empty, produce no output.
Note: Use stdin for reading input and stdout for printing output. If any mathematical formulas are needed, use LaTeX format. In this problem there is no complex formula needed.
inputFormat
The input consists of a single line containing a string s
composed only of lowercase letters. The string may be empty.
Input is read from stdin.
outputFormat
For each distinct letter in the input string, print a line in the format letter: count
, where letter
is the character and count
is its number of occurrences. The output lines must be ordered by the letter in alphabetical order. If the input string is empty, do not print anything.
Output should be written to stdout.
## sampletest
e: 1
s: 1
t: 2
</p>