Answers for "print all subsets of a string"

C++
0

print all subsets of a string

#include <iostream>

using namespace std;
void solve(string s,string op)
{
    if(s.size()==0)
    {
        cout<<op<<endl;
        return;
    }
    string op1=op;
    string op2=op;
    op2.push_back(s[0]);
    s.erase(s.begin()+0);
    solve(s,op1);
    solve(s,op2);
}
int main()
{
    string s;
    cin>>s;
    string op="";
    solve(s,op);
    return 0;
}
Posted by: Guest on September-24-2021

Code answers related to "print all subsets of a string"

Browse Popular Code Answers by Language