Advertisement
heian

Untitled

May 18th, 2019
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.84 KB | None | 0 0
  1. #include <fstream>
  2. #include <fstream>
  3.  
  4. using namespace std;
  5.  
  6. ifstream fin("date.in");
  7. ofstream fout("date.out");
  8.  
  9. int n;
  10. int st[20];
  11.  
  12. void Afisare()
  13. {
  14. int i, nr1=0;
  15.  
  16. for(i=1;i<=n;++i)
  17. nr1+=st[i];
  18. if(nr1==0)
  19. return;
  20.  
  21. for(i=1;i<=n;++i)
  22. if(st[i]==1)
  23. fout<<i<<" ";
  24. fout<<"\n";
  25. }
  26.  
  27. void Back(int k)
  28. {
  29. if(k==n+1)
  30. Afisare();
  31. else
  32. {
  33. //cout<<"k="<<k<<"\n";
  34. int i;
  35. for(i=0;i<=1;i++)
  36. {
  37. //daca st[i]==1, inseamna ca i apare in submultimea
  38. //respective
  39. st[k] = i;
  40. Back(k+1);
  41. }
  42. }
  43.  
  44. }
  45.  
  46. int main()
  47. {
  48. #ifndef ONLINE_JUDGE
  49. freopen ("date.in","r",stdin);
  50. freopen ("date.out","w",stdout);
  51. #endif
  52. n=3;
  53. Back(1);
  54.  
  55. return 0;
  56. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement