Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- int n,st[20];
- void BACK(int top)
- {
- int i;
- if(top==(n+1))
- {
- for(i=1;i<=n-2 && (st[i]!=1 || st[i+1]!=1 && st[i+2]!=1); i++)
- ;
- if(i==(n-1))
- {
- for(int i=1;i<=n;i++)
- cout<<st[i]<<" ";
- cout<<"\n";
- }
- }
- else for(int i=0;i<=1;i++)
- {
- st[top]=i;
- BACK(top+1);
- }
- }
- int main()
- {
- cin>>n;
- BACK(1);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement