// ERROR A PROPÓSITO: el elemento usado nunca vuelve a quedar libre.
#include <stdio.h>
#include <string.h>

#define MAX_ITEMS 16

static void permutations(const char *items, int n, char *current, int *used, int depth) {
    if (depth == n) {
        current[n] = '\0';
        printf("%s\n", current);
        return;
    }
    for (int i = 0; i < n; i++) {
        if (!used[i]) {
            used[i] = 1;
            current[depth] = items[i];
            permutations(items, n, current, used, depth + 1);
            // falta used[i] = 0;
        }
    }
}

int main(void) {
    const char *items = "abc";
    char current[MAX_ITEMS + 1];
    int used[MAX_ITEMS] = {0};

    permutations(items, (int) strlen(items), current, used, 0);
    return 0;
}
