C++ program to expand the given string

C++ program to expand the following string
aa2b4c3d
o/p should be :
aabbccccddd

Questions by manish521

Showing Answers 1 - 10 of 10 Answers

Sanjib

  • Mar 27th, 2014
 

Code
  1. #include<iostream.h>

  2. #include<conio.h>

  3. #include<string.h>

  4. "

  5. Enter the string to expand:

  6. ""

  7. -------OUTPUT-------------

  8. "



  Was this answer useful?  Yes

pankaj

  • Jul 23rd, 2014
 

input : p3s
output: psss

  Was this answer useful?  Yes

Aparna

  • Oct 19th, 2014
 

Code:

Code
  1. #include <iostream>

  2. #include <string.h>

  3. "Enter String""Output"

  Was this answer useful?  Yes

Ashish

  • Oct 31st, 2014
 

Code
  1. #include <iostream>

  2. #include <string>

  3. #include <stdlib.h>

  4. "Hello World""aa22b4c3d"//cout << str[i] << endl;



  Was this answer useful?  Yes

siva

  • Nov 6th, 2014
 

Below logic will work correctly. I think the first answe wont work if we have more than 2 digits like 222. But below one is generalized code and work for all sequence.

Code
  1.  

  2. #include <iostream>

  3. #include <string>

  4. #include <stdlib.h>

  5. "Hello World""aa22b4c3d"

  Was this answer useful?  Yes

Matvey

  • Mar 16th, 2015
 

Code
  1. #include <iostream>

  2. #include <string>

  3. "You have to enter a word"

  Was this answer useful?  Yes

caps

  • Sep 24th, 2015
 

This code should work for both multiple digits and multiple characters.

Code
  1. #include <string>

  2. """1234567890"

  Was this answer useful?  Yes

Narendra

  • Oct 1st, 2015
 

Code
  1. // Making the code as simple as I can.

  2. #include <iostream>

  3. #include <string>

  4. "Provide the input

  5. "// this is to check >0 && <10// for single characters

  Was this answer useful?  Yes

Jin Hyuk Cho

  • Feb 3rd, 2016
 

A working example

Code
  1. #include <iostream>

  2. #include <string>

  3. #include <locale>

  4. #include <sstream>

  5. // given aa2b4c

  6. // result aabbcccc

  7. "aa2b4c3d"

  Was this answer useful?  Yes

Sai Vamshi

  • Nov 25th, 2018
 

Code
  1. #include <iostream>

  2. #include<string.h>

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions