Advertisement
Saleh127

print_all_subset

Aug 6th, 2020 (edited)
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.54 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. void subset(int a[], int len, int c[], int len2, int index)
  4. {
  5. if (index >= len)
  6. {
  7. for (int i = 0; i < len2; ++i)
  8. {
  9. printf("%d ", c[i]);
  10. }
  11. printf("\n");
  12.  
  13. return;
  14. }
  15. subset(a, len, c, len2, index+1);
  16.  
  17. c[len2] = a[index];
  18.  
  19. subset(a, len, c, len2+1, index+1);
  20. }
  21. int main()
  22. {
  23. int a[10000];
  24. for(int i=0;i<3;i++)
  25. {
  26. a[i]=i+1;
  27. }
  28. int c[1000] = {0};
  29.  
  30. subset(a, 3, c, 0, 0);
  31. }
  32.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement