Advertisement
tanasaradu

Untitled

Nov 23rd, 2017
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.50 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. int n,st[20];
  4. void BACK(int top)
  5. {
  6. int i;
  7. if(top==(n+1))
  8. {
  9. for(i=1;i<=n-2 && (st[i]!=1 || st[i+1]!=1 && st[i+2]!=1); i++)
  10. ;
  11. if(i==(n-1))
  12. {
  13. for(int i=1;i<=n;i++)
  14. cout<<st[i]<<" ";
  15. cout<<"\n";
  16. }
  17. }
  18. else for(int i=0;i<=1;i++)
  19. {
  20. st[top]=i;
  21. BACK(top+1);
  22. }
  23. }
  24. int main()
  25. {
  26. cin>>n;
  27. BACK(1);
  28. return 0;
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement