fork download
  1. #include<bits/stdc++.h>
  2. #define ll long long
  3. using namespace std;
  4. int n;
  5. void bin(vector<int>a, int i)
  6. {
  7. if (i == n)
  8. {
  9. for (int it:a)
  10. cout << it;
  11. cout << '\n';
  12. return;
  13. }
  14. a.push_back(0);
  15. bin(a, i + 1);
  16. a.pop_back();
  17. a.push_back(1);
  18. bin(a, i + 1);
  19. }
  20.  
  21. int main() {
  22. ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  23. int t;
  24. cin>>t;
  25. while(t--) {
  26. cin>>n;
  27. vector<int> arr;
  28. arr.clear();
  29. bin(arr, 0);
  30. }
  31. }
Success #stdin #stdout 0.01s 5360KB
stdin
1
3
stdout
000
001
010
011
100
101
110
111