Advertisement
Guest User

powerset

a guest
Aug 31st, 2015
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.08 KB | None | 0 0
  1. void combinationUtil(set*,int n,int r,int index,string data[],int i);
  2.  
  3.  
  4. void printCombination(set* fr, int n, int r)
  5. {
  6.    
  7.     string data[r];
  8.  
  9.    
  10.     combinationUtil(fr, n, r, 0, data, 0);
  11. }
  12.  
  13.  
  14. void combinationUtil(set* fr, int n, int r, int index, string data[], int i)
  15. {
  16.    
  17.     if (index == r)
  18.     {
  19.         cout<<"{";
  20.         for (int j=0; j<r; j++)
  21.  
  22.             //cout<<data[j];
  23.         ;cout<<"}";
  24.         return;
  25.     }
  26.  
  27.    
  28.     if (i >= n)
  29.         return;
  30.     cur = fr;
  31.     int j = i;
  32.     while(j--){
  33.         cur=cur->next;
  34.        
  35.     }
  36.    
  37.     data[index] = cur->name;
  38.     combinationUtil(fr, n, r, index+1, data, i+1);
  39.  
  40.    
  41.     combinationUtil(fr, n, r, index, data, i+1);
  42. }
  43. string powerSet(char x){
  44.     set1=search(x);
  45.     set1=set1->next;
  46.     //cout<<set1->name;
  47.     int count=0,i;
  48.     while(set1){
  49.        
  50.         set1=set1->next;
  51.         //cout<<set1->name;
  52.         count++;
  53.     }
  54.     set1=search(x);
  55.     set1=set1->next;
  56.     for(i=0;i<=count;i++)
  57.         printCombination(set1,4,i);
  58.    
  59.        
  60.     return "hello";
  61. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement