z0 = x and z2
z1 = (not x and z0) or (z1 and x)
z2 = (z1 and not x) or (z0 and x) or (z2 and not x)
y = z2 or (z1 and not x) or z0
z0 = x and z2
z1 = (not x and z0) or (x and z1)
z2 = (x and z0) or (not x and z1) or (not x and z2)
y = z0 or (not x and z1) or z2
z0 = x and z2
z1 = ((not x) and z0) or (x and z1)
z2 = (x and z0) or ((not x) and z1) or ((not x) and z2)
y = z0 or ((not x) and z1) or z2
z2 z1 z0 | x | z2 z1 z0 | y
0 0 0 | 0 |
0 0 0 | 1 |
0 0 1 | 0 |
0 0 1 | 1 |
0 1 0 | 0 |
0 1 0 | 1 |
0 1 1 | 0 |
0 1 1 | 1 |
1 0 0 | 0 |
1 0 0 | 1 |
1 0 1 | 0 |
1 0 1 | 1 |
1 1 0 | 0 |
1 1 0 | 1 |
1 1 1 | 0 |
1 1 1 | 1 |
#include <stdio.h>
#define and &&
#define or ||
#define not !
int main (void) {
int x, z2, z1, z0;
for (z2 = 0; z2 <= 1; z2++) {
for (z1 = 0; z1 <= 1; z1++) {
for (z0 = 0; z0 <= 1; z0++) {
for (x = 0; x <= 1; x++) {
printf ("%i %i %i %i %i %i %i %i\n", z2, z1, z0, x, (x and z0) or ((not x) and z1) or ((not x) and z2), ((not x) and z0) or (x and z1), x and z2, z0 or ((not x) and z1) or z2);
}
}
}
}
return 0;
}
0 0 0 0 0 0 0 0
0 0 0 1 0 0 0 0
0 0 1 0 0 1 0 1
0 0 1 1 1 0 0 1
0 1 0 0 1 0 0 1
0 1 0 1 0 1 0 0
0 1 1 0 1 1 0 1
0 1 1 1 1 1 0 1
1 0 0 0 1 0 0 1
1 0 0 1 0 0 1 1
1 0 1 0 1 1 0 1
1 0 1 1 1 0 1 1
1 1 0 0 1 0 0 1
1 1 0 1 0 1 1 1
1 1 1 0 1 1 0 1
1 1 1 1 1 1 1 1
Jetzt gibt es einen Witz: Sie haben gesagt: Das Schaltwerk benutzt Hot-One-Kodierung:
https://de.wikipedia.org/wiki/1-aus-n-Code
Dann machen wir das anders.
#include <stdio.h>
#define and &&
#define or ||
#define not !
int main (void) {
int x, z2, z1, z0;
/*
for (z2 = 0; z2 <= 1; z2++) {
for (z1 = 0; z1 <= 1; z1++) {
for (z0 = 0; z0 <= 1; z0++) {
for (x = 0; x <= 1; x++) {
printf ("%i %i %i %i %i %i %i %i\n", z2, z1, z0, x, (x and z0) or ((not x) and z1) or ((not x) and z2), ((not x) and z0) or (x and z1), x and z2, z0 or ((not x) and z1) or z2);
}
}
}
}
*/
x = 0;
z0 = 1;
z1 = 0;
z2 = 0;
printf ("%i %i %i %i %i %i %i %i\n", z2, z1, z0, x, (x and z0) or ((not x) and z1) or ((not x) and z2), ((not x) and z0) or (x and z1), x and z2, z0 or ((not x) and z1) or z2);
x = 1;
z0 = 1;
z1 = 0;
z2 = 0;
printf ("%i %i %i %i %i %i %i %i\n", z2, z1, z0, x, (x and z0) or ((not x) and z1) or ((not x) and z2), ((not x) and z0) or (x and z1), x and z2, z0 or ((not x) and z1) or z2);
x = 0;
z0 = 0;
z1 = 1;
z2 = 0;
printf ("%i %i %i %i %i %i %i %i\n", z2, z1, z0, x, (x and z0) or ((not x) and z1) or ((not x) and z2), ((not x) and z0) or (x and z1), x and z2, z0 or ((not x) and z1) or z2);
x = 1;
z0 = 0;
z1 = 1;
z2 = 0;
printf ("%i %i %i %i %i %i %i %i\n", z2, z1, z0, x, (x and z0) or ((not x) and z1) or ((not x) and z2), ((not x) and z0) or (x and z1), x and z2, z0 or ((not x) and z1) or z2);
x = 0;
z0 = 0;
z1 = 0;
z2 = 1;
printf ("%i %i %i %i %i %i %i %i\n", z2, z1, z0, x, (x and z0) or ((not x) and z1) or ((not x) and z2), ((not x) and z0) or (x and z1), x and z2, z0 or ((not x) and z1) or z2);
x = 1;
z0 = 0;
z1 = 0;
z2 = 1;
printf ("%i %i %i %i %i %i %i %i\n", z2, z1, z0, x, (x and z0) or ((not x) and z1) or ((not x) and z2), ((not x) and z0) or (x and z1), x and z2, z0 or ((not x) and z1) or z2);
return 0;
}
Dabei kommt heraus:
0 0 1 0 0 1 0 1
0 0 1 1 1 0 0 1
0 1 0 0 1 0 0 1
0 1 0 1 0 1 0 0
1 0 0 0 1 0 0 1
1 0 0 1 0 0 1 1
Auf den Zustand 0, habe ich verzichtet, weil, der hat als Folgezustand 0
Also haben wir die Zustände:
0 0 1
0 1 0
1 0 0
Nur so viele müssen wir in unseren Zustandsgraph einbauen.