/media/sda-magnetic/david/Extern-Magnetic-2022-06-29/Extern01/Dokumente-11-2021-07-05/informatik-math/informatik2/quine-mc-cluskey-asm-2021-04-16/xxx5.c


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

char bstr [9];

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;
    }
    bstr [8] = 0;
        
return bstr;
}

int main (void) {
    int x0, x1, x2, x3;
    time_t t;
    int i, j;
    int x;
    
    int a [16];
    char str1 [16];
    char str2 [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; ;  i = a [i]) {
        strcpy (str1, itob (i));
        strcpy (str2, itob (a[i]));
        printf( "%s    %s\n", str1, str2);                    
        if ( a[i] == 0)
            break;
    }
        
        
}