Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- using namespace std;
- int n;
- int a[100];
- void show(){
- for(int i=1;i<=n;i++){
- cout<<a[i];
- }
- }
- void backtrack (int pos){
- if (pos==n+1){
- show();
- cout<<endl;
- return ;
- }
- else {
- for(int i=0;i<=1;i++){
- // cac gia tri co trong tap hoan vi
- a[pos]=i;
- backtrack(pos+1);
- }
- }
- }
- int main(){
- cin>>n;
- backtrack(1);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment