Advertisement
Guest User

Untitled

a guest
Oct 18th, 2017
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.57 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4. int x[100],n,m;
  5.  
  6. void afis(int k)
  7. {
  8. int i;
  9. cout<<"{";
  10. for(i=1; i<=k; i++)
  11. if (x[i]!=0)
  12. cout<<i<<" ";
  13. cout<<"}"<<endl;
  14. }
  15. void BT()
  16. {
  17. int k;
  18. k=1;
  19. x[k]=-1;
  20. while(k>0)
  21. if(x[k]<1)
  22. {
  23. x[k]=x[k]+1;
  24. if(k==n)
  25. afis(k);
  26. else
  27. {
  28. k++;
  29. x[k]=-1;
  30.  
  31. }
  32. }
  33. else k--;
  34. }
  35.  
  36.  
  37. int main()
  38. {
  39. cin>>n;
  40. BT();
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement