fork download
  1. #include <iostream>
  2. #include <string>
  3.  
  4. using namespace std;
  5.  
  6. void gen(int n, string s) {
  7. if(n == 0){
  8. cout<<s<<endl;
  9. return;
  10. }
  11. gen(n - 1, s + "0");
  12. gen(n - 1, s + "1");
  13. }
  14.  
  15. int main(){
  16. int n;
  17. cin>>n;
  18. gen(n, "");
  19. return 0;
  20. }
  21.  
Success #stdin #stdout 0.01s 5324KB
stdin
Standard input is empty
stdout