Advertisement
Guest User

Untitled

a guest
Oct 17th, 2019
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.80 KB | None | 0 0
  1. #include <iostream>
  2. #include <fstream>
  3. using namespace std;
  4. ifstream f ("submultimi1.in");
  5. ofstream g ("submultimi1.out");
  6. int n,st[100],k;
  7. void init()
  8. {
  9. st[k]=0;
  10. }
  11. int succesor()
  12. {
  13. while(st[k]<n)
  14. {
  15. st[k]++;
  16. return 1;
  17. }
  18. return 0;
  19. }
  20. int valid()
  21. {
  22. if(k>1)
  23. if(st[k]-st[k-1]==1)
  24. return 0;
  25. if(st[k-1]>=st[k])
  26. return 0;
  27. return 1;
  28. }
  29. void tipar()
  30. {
  31. for(int i=1;i<=k;i++)
  32. g<<st[i]<<' ';
  33. g<<endl;
  34. }
  35. void bak()
  36. {
  37. int as;
  38. k=1;
  39. init();
  40. while(k>0)
  41. {
  42. while((as=succesor()) && !valid());
  43. if(as)
  44. {
  45. tipar();
  46. k++;
  47. init();
  48. }
  49. else
  50. k--;
  51. }
  52. }
  53. int main()
  54. {
  55. f>>n;
  56. bak();
  57. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement