/media/sda-magnetic/david/Dok-15-2023-11-27/fernuni-hagen/cs-i-ii/old-cs-2-01/informatik2/2021-04-21quine-state-.../xxx6.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 y;
    
    int a [16];
    int b [16];
    char str1 [16];
    char str2 [16];
    char str3 [16];

    
    srand((unsigned) time(&t));
    
    a [0] = rand () % 16;
    
    for (i = 1;  i < 16;) {
        x = rand () % 16;
        y = rand () % 16;
        for (j = 0; j < i;  j++) {
            if (a[j] == x)
                break;
        }
        if (j == i) {
            a [i] = x;
            b [i] = y;
            i++;
        }
    }
    
    for (i = 0; ;  i = a [i]) {
        strcpy (str1, itob (i));
        strcpy (str2, itob (a[i]));
        strcpy (str3, itob (b[i]));
        printf( "%s    %s    %s\n", str1, str2, str3);                    
        if ( a[i] == 0)
            break;
    }
        
        
}