Skip to content

Commit 6f45d9e

Browse files
committed
recursive concept
1 parent 3cc4b75 commit 6f45d9e

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

stringsubset.cpp

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#include <bits/stdc++.h>
2+
using namespace std;
3+
void printsub(string str, string curr=" ", int index=0)
4+
{
5+
if(index==str.length())
6+
{
7+
cout<<curr;
8+
return;
9+
}
10+
printsub(str,curr,index+1);
11+
printsub(str,curr+str[index],index+1);
12+
}
13+
int main()
14+
{
15+
ios::sync_with_stdio(false);
16+
cin.tie(0);
17+
string s="ABC";
18+
printsub(s);
19+
return 0;
20+
}

0 commit comments

Comments
 (0)