Submitted Questions

  • C++ program to expand the given string

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

    Sai Vamshi

    • Nov 25th, 2018

    Code
    1. #include <iostream>
    2. #include<string.h>
    3. using namespace std;
    4.  
    5. int main()
    6. {
    7.     char *str;
    8.     cin>>str;
    9.     int len = strlen(str);
    10.     for(int i=0;i<len;i+=2){
    11.             for(int j=0;j<(str[i+1]-0);j++){
    12.                 cout<<str[i];
    13.             }
    14.     }
    15.     return 0;
    16. }
    17.  

    Jin Hyuk Cho

    • Feb 3rd, 2016

    A working example"cpp #include #include #include #include using namespace std; string expand (string compressed) { locale loc; stringstream ss; // g...