02 Apr PMCA Sunday 10:00 Java Homework 20.03.29.
You have come up with the following compression technique: for each symbol, write down the number of times it appears consecutively, followed by the symbol itself. This compression technique is called run-length encoding.
Given a sequence of characters, write a program to encode them in this format: The encoding of a line will be a sequence of pairs, separated by a space, where each pair is an integer (representing the number of times the character appears consecutively) followed by a space, followed by the character.
Sample Input 1:
Output for Sample Input 1:
3 + 3 = 4 !
Explanation of Output for Sample Input
To see how the first message (on the second line of input) is encoded, notice that there are 3 + symbols, followed by 3 = symbols, followed by 4 ! symbols.
Sample Input 2:
Output for Sample Input 2:
6 7 6 . 12 T
Sorry, the comment form is closed at this time.