Re: Aufgaben und Übungen,

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


#define MAX_SPECIAL_STATES      3
#define MAX_STATES              8
#define MIN_STATE               1
#define SPECIAL_STATE_1         1
#define SPECIAL_STATE_2         2
#define SPECIAL_STATE_3         3
#define MAX_INPUTS              2

int main (void) {
    time_t t;
    int i;
    int q [MAX_SPECIAL_STATES];
    int j;
    int a [MAX_STATES];
    int b [MAX_STATES];
    int x [MAX_STATES];

    srand ((int)time (\&amp;t));

    q [SPECIAL_STATE_1] = (rand () % MAX_STATES) + MIN_STATE;
    while ((q [SPECIAL_STATE_2] = ((rand () % MAX_SPECIAL_STATES)+MIN_STATE)) == q [SPECIAL_STATE_1]);
    while (((q [SPECIAL_STATE_3] = ((rand () % MAX_STATES)+MIN_STATE)) == q [SPECIAL_STATE_1]) || (q [SPECIAL_STATE_3] == q [SPECIAL_STATE_2]));
    j = rand () % MAX_INPUTS;

    printf ("Zur Sicherheit: %i %i %in", q [SPECIAL_STATE_1], q [SPECIAL_STATE_2], q [SPECIAL_STATE_3]);

    printf ("ZustandttFolge-Zustand fuertAusgangn");
    printf ("tttx=0tx=1ttttn");
    for (i = MIN_STATE;  i < (MAX_STATES+MIN_STATE);  i++) {
        if (i == q [SPECIAL_STATE_1]) {
            a [q [SPECIAL_STATE_1] - MIN_STATE] = q [SPECIAL_STATE_2];
            b [q [SPECIAL_STATE_1] - MIN_STATE] = q [SPECIAL_STATE_3];
            x [q [SPECIAL_STATE_1] - MIN_STATE] = j;
        }
        else if (i == q [SPECIAL_STATE_2]) {
            a [q [SPECIAL_STATE_2] - MIN_STATE] = q [SPECIAL_STATE_3],
            b [q [SPECIAL_STATE_2] - MIN_STATE] = q [SPECIAL_STATE_1];
            x [q [SPECIAL_STATE_2] - MIN_STATE] = j;
        }
        else if (i == q [SPECIAL_STATE_3]) {
            a [q [SPECIAL_STATE_3] - MIN_STATE] = q [SPECIAL_STATE_1];
            b [q [SPECIAL_STATE_3] - MIN_STATE] = q [SPECIAL_STATE_2];
            x [q [SPECIAL_STATE_3] - MIN_STATE] = j;
        }
        else {
             a [i - MIN_STATE] = (rand () % MAX_STATES) + 1;
             b [i - MIN_STATE] = (rand () % MAX_STATES) + 1;
             x [i - MIN_STATE] = (rand () % MAX_INPUTS);
        }
    }
    for (i = MIN_STATE;  i < (MAX_STATES + MIN_STATE);  i++)
        printf ("%ittt%it%itttt%in", i - MIN_STATE,  a [i - MIN_STATE], b [i - MIN_STATE], x [i - MIN_STATE]);
return 0;
}