#C2263. Run-Length Encoding Compression
Run-Length Encoding Compression
Run-Length Encoding Compression
In this problem, you are required to perform run-length encoding (RLE) on input strings. For each consecutive sequence of identical characters, output the character followed by a comma and the count of that character. For example, the string AAAABBBCCDAA
should be compressed as A,4B,3C,2D,1A,2
.
The input will begin with an integer indicating the number of test cases. Each test case is given on its own line. For each test case, output the RLE compressed result on a separate line. Note that if the string is empty, the output should also be an empty line.
Please implement your solution so that it reads input from stdin and writes the output to stdout. Make sure your solution can handle multiple test cases in one run.
inputFormat
The first line of input contains an integer n, representing the number of test cases. Each of the next n lines contains a string that needs to be compressed using run-length encoding.
outputFormat
For each test case, output the compressed string on a new line. If an input string is empty, output an empty line.
## sample1
AAAABBBCCDAA
A,4B,3C,2D,1A,2
</p>