/media/sda-magnetic/david/Dok-15-2023-11-27/fernuni-hagen/cs-i-ii/old-cs-2-01/informatik2/quine-mc-cluskey-asm-2021-04-16/xxx3.c


#include <stdio.h>
#include <stdlib.h>
#include <time.h>

char bstr [8];

char *itob (int x) {
    int i;
    
    for (i = 0;  i < 8;  i++)
        bstr [i] = ' ';
    
    for (i = 7;  i >= 0;  i-=2) {
        bstr [i] = (x % 2) + '0';
        x = x/2;
    }
        
return bstr;
}

int main (void) {
    int x0, x1, x2, x3;
    time_t t;
    int i, j;
    int x;
    
    int a [16];

    
    srand((unsigned) time(&t));
    
    a [0] = rand () % 16;
    
    for (i = 1;  i < 16;) {
        x = rand () % 16;
        for (j = 0; j < i;  j++) {
            if (a[j] == x)
                break;
        }
        if (j == i) {
            a [i] = x;
            i++;
        }
    }
    
    for (i = 0, x3 = 0;  x3 <= 1;  x3++) {
        for (x2 = 0;  x2 <= 1;  x2++) {
            for (x1 = 0;  x1 <= 1;  x1++) {
                for (x0 = 0;  x0 <= 1;  x0++, i++) {
                    printf( "%i %i %i %i    %s\n", x3, x2, x1, x0, itob (a[i]));                    
                }
            }
        }
    }
}