# Include <iostream>
Using namespace STD;
Const int n= 1000;
Void selsubstr (INT flag [], int count)
{
For (INT I = 0; I <count; I ++)
{
Flag [I] = Flag [I] ^ 1;
// Stop if the value is 0 after the current element is reversed. In this way, there are 2 ^ n-1 cases, and there are no duplicates.
If (! Flag [I])
Break;
}
}
Void print (INT flag [], int count, const char * STR, char * substr)
{
Int J = 0;
For (INT I = 0; I <count; I ++)
{
If (flag [I]) // place the character to be output in substr
Substr [J ++] = STR [I];
}
Substr [J] = '/0 ';
Cout <substr <Endl;
}
Int main ()
{
Char * STR = new char [N]; // original string
Char * substr = new char [N]; // temporary string storage for the subset
Cout <"input a string :";
Cin. Getline (STR, N );
Int COUNT = strlen (STR );
int * flag = new int [count];
// when the default start is set, all elements are not displayed.
for (INT I = 0; I flag [I] = 0;
cout <"as follow is substr:" int substrcount = 0; // count the number of subsets
int q = 2 <(count-1 ); // calculate the number of cycles
for (INT I = 0; I {< br> selsubstr (flag, count ); // obtain the substring (subset)
Print (flag, Count, STR, substr); // display the substring (subset)
substrcount ++;
}< br> cout <"Total number of the subset (include empty-set) is:" return 0;
}