ZIP is an archive file format that supports lossless data compression. There are many way to zip compress data nowadays, such as RLE, LZW,Huffman Coding ans so on. Today your friend think out a method similiar as RLE(run length encoding) to compress data.
The zip way purpose by your friend:
Given the sequence contain only English letter or digit, the runs of data(sequences in which the same data value occurs in many consecutive data elements) will be store as a single data value and count, rather than as the original run.
Take squence aaabbb444 for example, aaabbb444 can be encoded to 3a3b3'4'
When there are less than three consecutive "letters", you don't need to compress it.
For example, aabbbdcccc can be encoded to aa3bd4c.
For those non-consecutive "digits", simply store the digit, you don't need to store the count.
For example, aabbb1ccc2dd33dd can be encoded to aa3b'1'3c'2'dd2'3'dd
Besides encoding, your friend is also interested in the compress rate of the result, which is defined by
Compress Rate = (length of the encoded string)/(length of the original string).
He ask you to help him implement the zip algoithm program and analysis the compress rate of the method. As the best friend of you, you decided to try your best to finish the program.
Given a sequence contain only English letter or digit.
(2 <= the length of the sequence <= 1000)
Print out the zip string and the compression rate, both followed by a newline character.
If the compression rate is less than 1.0 then print out "Compress rate: X.XXX" with the result (round to the third digit after the decimal point), otherwise print out "The string can't zip".
You can use printf("Compress rate: %.3f\n", rate) for printing the result.