Advertisement
Guest User

Untitled

a guest
Dec 20th, 2014
159
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.83 KB | None | 0 0
  1.  
  2. #include <iostream>
  3. #include <vector>
  4. using namespace std;
  5.  
  6. void bt(vector<string>& s,vector<int>& ss,int call,int p){
  7.     if(call<0){
  8.         for(int i=1;i<=p;++i){
  9.             cout << "subconjunt " << i <<": {";
  10.             bool coma=false;
  11.             for(int j=0;j<ss.size();++j){
  12.                 if(ss[j]==i){
  13.                     if(coma) cout << ',';
  14.                     coma=true;
  15.                     cout << s[j];
  16.                 }
  17.             }
  18.             cout << "}" << endl;
  19.         }
  20.         cout << endl;
  21.     }else{
  22.         for(int i=1;i<=p;++i){
  23.             ss[call]=i;
  24.             bt(s,ss,call-1,p);
  25.         }
  26.     }
  27. }
  28.  
  29. int main(){
  30.     int n,p;
  31.     cin >> n;
  32.     vector< string > inp(n);
  33.     vector< int    > ss(n,1);
  34.     for(int i=0;i<n;++i) cin >> inp[i];
  35.     cin >> p;
  36.     bt(inp,ss,n-1,p);
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement