lets say this is the code to solve the substring of a char array
#include <bits/stdc++.h>
using namespace std;
void powerset(char *s){
for(int i=0;s[i]!=’\0’;i++){
for(int j=i;s[j]!=’\0’;j++){
for(int k=i;k<=j;k++){
cout<<s[k];
}
cout<<endl;
}
}
}
int main()
{
char str[100];
cin.getline(str,100);
powerset(str);
return 0;
}
input and output will be following :
abc
output:
a
ab
abc
b
bc
c
what if i want to print all elements like
a
b
c
ab
bc
ac
abc
any suggestion?