Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- using namespace std;
- void bt(vector<string>& s,vector<int>& ss,int call,int p){
- if(call<0){
- for(int i=1;i<=p;++i){
- cout << "subconjunt " << i <<": {";
- bool coma=false;
- for(int j=0;j<ss.size();++j){
- if(ss[j]==i){
- if(coma) cout << ',';
- coma=true;
- cout << s[j];
- }
- }
- cout << "}" << endl;
- }
- cout << endl;
- }else{
- for(int i=1;i<=p;++i){
- ss[call]=i;
- bt(s,ss,call-1,p);
- }
- }
- }
- int main(){
- int n,p;
- cin >> n;
- vector< string > inp(n);
- vector< int > ss(n,1);
- for(int i=0;i<n;++i) cin >> inp[i];
- cin >> p;
- bt(inp,ss,n-1,p);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement