fork download
  1. #include <stdio.h>
  2.  
  3. void recur(int flag[], int n, int idx) {
  4. if (idx == n) {
  5. for (int i = 0; i < n; i++) {
  6. if (flag[i]) {
  7. printf("%d ", i);
  8. }
  9. }
  10. printf("\n");
  11. return;
  12. }
  13.  
  14. recur(flag, n, idx + 1);
  15. int temp = flag[idx];
  16. flag[idx] = 1;
  17. recur(flag, n, idx + 1);
  18. flag[idx] = temp;
  19. }
  20.  
  21. int main() {
  22. int flag[] = {0, 0, 0};
  23. recur(flag, 1, 0);
  24. return 0;
  25. }
Success #stdin #stdout 0s 5272KB
stdin
Standard input is empty
stdout
0