I am making the power set of string and storing in a 2D array and now I want to store the whole power set element into a single 1D array? I am coding on CodeBlocks.
String s1="abba"
and arr[][]
is also of string
class.
for(int i=0;i<(1<<s1.length());i++)
{
for(int j=0;j<s1.length();j++)
{
if((i&(1<<j))>0)
{ if(k<1<<s1.length())
arr[i][j]=s1[j];
}
}
}
for(int i=0;i<(1<<s1.length());i++)
{
for(int j=0;j<s1.length();j++)
{
if((i&(1<<j))>0)
{ if(k<1<<s1.length())
cout<<arr[i][j];
}
}
}
I want to store these element in a 1D array to process it.