Power Set

PHOTO EMBED

Tue Oct 12 2021 02:17:03 GMT+0000 (Coordinated Universal Time)

Saved by @code_ea

#include <iostream>
#include <cmath>
using namespace std;

void printPowerSet(string str)
{
	int n = str.length();

	int powSize = pow(2, n);

	for(int counter = 0; counter < powSize; counter++)
	{
		for(int j = 0; j < n; j++)
		{
			if((counter & (1 << j)) != 0)
                cout<<str[j];
		}
		
		cout<<endl;
	}
}
    

    
int main() {
	
	string s = "abc";

    printPowerSet(s);  
    
}
content_copyCOPY

https://ide.geeksforgeeks.org/H3wPxim28h