幂集子集 (二进制进)

#include<iostream>
using namespace std;
string a[100];

void dowhat(int n){
	cout<<"empty ";
	for(int i=0;i<(1<<n);i++){
		if(i!=0) cout<<"{"; 
		for(int j=0;j<n;j++){
			if(i & (1<<j)){
				cout<<a[j]<<" ,";
			}
		}
		if(i!=0) cout<<"}"; 
	}
}


int main(){
	int n;
	cin>>n;
	for(int j=0;j<n;j++){
		cin>>a[j];
	}
	dowhat(n);
	
	
	
	return 0;
}
发布了27 篇原创文章 · 获赞 1 · 访问量 1673

猜你喜欢

转载自blog.csdn.net/qq_37959151/article/details/89737470
今日推荐