Logo 
Search:

C++ Programming Article

Submit Article
Comments on Program to represent or compress ‘2ABCDE' to string ‘AABCDE'’

Each line in the input file will be of the format ‘nA...’ where n, the duplication factor, is an integer between 2 and 99 and A is an uppercase alphabetic character. A string may contain single characters not prefixed with a duplication factor. If this were not the case, for instance, the string ‘AABCDE’ would be compressed to ‘2A1B1C1D1E’. To avoid this, single characters will not be prefixed with a duplication factor. The string ‘AABCDE’ would be compressed to ‘2ABCDE’. The maximum length of each line in input file is 80 characters.

The uncompressed string, 40 characters per line (it may be necessary to break an uncompressed string over multiple lines).


Ian Serben
Ian Serben from United StatesJul 03
How about the other way around? If I input say, 2A3Bc, I want to get the output AABBBc. Also, how about if I don't want to get the innput from an external .txt file?


Please enter your Comment
  • Comment should be atleast 15 Characters.
  • Please put code inside [Code] your code [/Code].