Write the program to make substring of a string.


#include
<iostream>

#include<string>

using namespace std;

  void substring(string a,string ans)
  { if (a.size()==0)
       {cout<<ans <<endl;
     return;}
     char c=a[0];
     string ros=a.substr(1);
     substring(ros,ans);
     substring(ros ,ans+c);
    }

  int main()
{
    string a ="ABC";
    string b ="";
    
    substring(a,b);
   
    return 0;
}

Comments

Popular posts from this blog

Use of Recursion