Print all possible strings that can be made by placing spaces | C ++ program to print all strings that can be made by placing spaces ; Function to print all subsequences ; Driver code
#include <bits/stdc++.h> NEW_LINE using namespace std ; void printSubsequences ( string str ) { int n = str . length ( ) ; unsigned int opsize = pow ( 2 , n - 1 ) ; for ( int counter = 0 ; counter < opsize ; counter ++ ) { for ( int j = 0 ; j < n ; j ++ ) { cout << str [ j ] ; if ( counter & ( 1 << j ) ) cout << " ▁ " ; } cout << endl ; } } int main ( ) { string str = " ABC " ; printSubsequences ( str ) ; return 0 ; }