• Source
    1. #include <iostream>
    2. using namespace std;
    3.  
    4. char out[1000];
    5. int count=0;
    6.  
    7. void binaryStrings(char *out,int n,int j){
    8. //Base case
    9. if(j==n) {
    10. // out[j]=NULL;
    11. //cout<<out<<endl;
    12. count++;
    13. return;
    14. }
    15.  
    16. //Recursive case
    17. out[j]='0';
    18. binaryStrings(out,n,j+1);
    19. if(out[j-1]!='1'){
    20. out[j]='1';
    21. binaryStrings(out,n,j+1);
    22. }
    23. }
    24.  
    25. int main() {
    26. // your code goes here
    27. int t;
    28. cin>>t;
    29. int n;
    30. while(t--){
    31. count=0;
    32. cin>>n;
    33. binaryStrings(out,n,0);
    34. cout<<count<<endl;
    35. }
    36. return 0;
    37. }
    38.