Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 1

#include <iostream>

#include <stdio.h>
/* run this program using the console pauser or add your own getch, system("pause")
or input loop */
#define max 100
int B[max], n=4;
//-----------------------------------//
void Print(int n){
int i;
for(i = 1; i <= n; i++)
printf("%d\t", B[i]);
printf("\n");
}
//-----------------------------------//
int F(int n){
if(n == 1 || n == 2)return 1;
return F(n - 1) + F(n - 2);
}
//-----------------------------------//
void Bit(int n){
int i, c, j;
for(i = 1; i <= n; i++)B[i]=!(i%2);
Print(n);
for(c = 1; c < F(n + 2); c++){
i = n;
while(B[i] == 1)i--;
B[i] = 1;
for(j = i + 1; j <= n; j++)B[j]=!B[j-1];
Print(n);
}
}
//-----------------------------------//
int main(int argc, char** argv) {
Bit(n);
return 0;
}

You might also like