#include <stdio.h>

#define MAX_IDX 2
#define MAX_VAL 1
#define INIT 0

void print_a(int* a){

    int i = 0;

    for (i = 0; i < MAX_IDX+1; i++){
        printf("%d ", a[i]);
    }
    printf("\n");

}

int check_init(int* a){

    int i;

    for (i = 0; i <= MAX_IDX; i++){
        if (a[i] != INIT) return 0;
    }

    return 1;

}

int recursive_increment(int idx, int* a){

    if (idx < MAX_IDX) {
        while (1){
            a[idx] += recursive_increment(idx + 1, a);
            if (a[idx] > MAX_VAL){
                a[idx] = INIT;
                return 1;
            }
            if (check_init(a)) break;
        }
        return 0;
    }
    else {
        print_a(a);
        if (a[idx] == MAX_VAL){
            a[idx] = INIT;
            return 1;
        }
        else{
            a[idx]++;
            return 0;
        }
    }

    return -1;
}

int main(void){

    int a[MAX_IDX + 1];
    int buf, i;

    for (i = 0; i < MAX_IDX + 1; i++){
        a[i] = INIT;
    }

    buf = recursive_increment(0, a);

    return 0;
}

