#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <string.h>
char bstr [5];
char *itob (int x) {
int i;
for (i = 0; i < 4; i++)
bstr [i] = ' ';
for (i = 3; i >= 0; i-=2) {
bstr [i] = (x % 2) + '0';
x = x/2;
}
bstr [4] = 0;
return bstr;
}
int main (void) {
int x0, x1, x2, x3;
time_t t;
int i, j;
int x;
int a [4];
char str1 [8];
char str2 [8];
srand((unsigned) time(&t));
a [0] = rand () % 4;
for (i = 1; i < 4;) {
x = rand () % 4;
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;
}
}