Re: Aufgaben und Übungen,

OK, das Programm tut jetzt

// Mein Problem ist, ich habe hier eine Bereichs"uberschreitung - und der Witz bei der Sache ist, dass ich ein Array habe, das geht so

//int y [MAX_OUTPUTS][MAX_STATES]
// und ich z"ahle die Schleife nach oben, bis
// und es kommt trotzdem zur Bereichs"uberschreitung
// Hier ist
// #define MAX_STATES              4
// #define MAX_OUTPUTS             2
// Und ich verstehe das Problem nicht

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

#define MAX_SPECIAL_STATES      3
#define MAX_STATES              4
#define MIN_STATE               1
#define SPECIAL_STATE_1         1
#define SPECIAL_STATE_2         2
#define SPECIAL_STATE_3         3
#define MAX_INPUTS              2
#define MAX_OUTPUTS             2
#define TRUE                    1
#define FALSE                   0
#define Z_A                     0
#define Z_B                     1

void readcsv (int a [], int b [], int y [MAX_OUTPUTS][MAX_STATES]) {
    int i;
    int j;
    int i1, i2;
    int x1, x2;
    scanf ("Zustand,Eingabe,Ausgabe,Folgezustandn");

    for (i = 0;  i < (MAX_STATES*MAX_OUTPUTS) ;  ) {
        scanf ("%i,%i,%i,%in", \&amp;i1, \&amp;x1, \&amp;y [Z_A][i/2], \&amp;a [i]);
        i++;
        scanf ("%i,%i,%i,%in", \&amp;i2, \&amp;x2, \&amp;y [Z_B][i/2], \&amp;b [i]);
        i++;

/*
        if (x1 != Z_A) {
            printf ("Error - I/On");
            exit (1);
        }
        if (x2 != Z_B) {
            printf ("Error - I/On");
            exit (1);
        }
        if (i1 != (i+1)) {
            printf ("Error - I/On");
            exit (1);
        }
        if (i2 != (i+1)) {
            printf ("Error - I/On");
            exit (1);
        }*/
    }

return;
}

void printcsv (int a [], int b [], int y [MAX_OUTPUTS][MAX_STATES]) {
    int i;
    printf ("Zustand,Eingabe,Ausgabe,Folgezustandn");

    for (i = 0;  i < (MAX_STATES);  i++) {
        printf ("%i,%i,%i,%in", i+MIN_STATE, Z_A, y [Z_A][i], a [i]);
        printf ("%i,%i,%i,%in", i+MIN_STATE, Z_B, y [Z_B][i], b [i]);
    }

return;
}

void createnew (int a [], int b [], int y [MAX_OUTPUTS][MAX_STATES]) {
#define RAND_1      32
#define RAND_2      16
#define RAND_3      16
#define RAND_4      8

    time_t t;
    int i, j;
    int z [MAX_STATES][MAX_OUTPUTS];
    int flag;

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

    for (i = 0;  i < MAX_STATES;  i++) {
        z [i][Z_A] = i + MIN_STATE;
        z [i][Z_B] = i + MIN_STATE;
    }
    flag = 0;
    while (!flag) {
        for (i = 0;  i < MAX_STATES;  i++) {
            for (j = i + 1;  j < MAX_STATES;  j++) {
                if ((rand () % RAND_1) > RAND_2) {
                    t = z [j][Z_A];
                    z [j][Z_A] = z[i][Z_A];
                    z [i][Z_A] = t;
                }
            }
        }
        for (i = 0;  i < MAX_STATES;  i++) {
            for (j = i + 1;  j < MAX_STATES;  j++) {
                if ((rand () % RAND_3) < RAND_4) {
                    t = z [j][Z_B];
                    z [j][Z_B] = z[i][Z_B];
                    z [i][Z_B] = t;
                }
            }
        }
        flag = TRUE;
        for (i = 0;  i < MAX_STATES;  i++)
            if ((z[i][Z_A] == z[i][Z_B]) \&amp;\&amp; (z[i][Z_B] == i)) {
                flag = FALSE;
            }

    }
    for (i = 0;  i < MAX_STATES;  i++) {
        a [i] = z [Z_A][i];
        b [i] = z [Z_B][i];
        y [Z_A][i] = rand () % MAX_OUTPUTS;
        y [Z_B][i] = rand () % MAX_OUTPUTS;
    }

return;
}

void printtex (int a [], int b [], int y [MAX_OUTPUTS][MAX_STATES]) {
    int i, j;
    printf("\documentclass{article}n");
    printf("\usepackage[utf8]{inputenc}n");
    printf("\usepackage{pgf, tikz}n");
    printf("\usetikzlibrary{arrows , automata , positioning}n");
    printf("\begin{document}nn");

    printf("\begin{center}n");
    printf("\begin{tikzpicture}[>=stealth',shorten >=1pt,auto,node distance=2.5cm]n");
    printf("%Knotenn");

    printf("\node (1) [state, thick] {1};n");
    printf("\node (2) [state, thick, right of= 1] {2};n");
    printf("\node (3) [state, thick, above of= 2, right of= 2] {3};n");
    printf("\node (4) [state, thick, above of= 3, right of= 1] {4};nn");

    printf("%Verbindungenn");
    printf("\path[thick,->]n");

    char *leftright [] = {"left", "right"};
    char *abovebelow [] = {"above", "below"};

    for (i = 0;  i < MAX_STATES;  i++) {
            if ((a [i] - MIN_STATE) == i)
                printf ("(%i) edge [loop] node {%i/%i} (%i)n", i + MIN_STATE, Z_A, y [Z_A][i], a [i]);
            else
                printf ("(%i) edge [bend angle=%i, bend %s,%s] node {%i/%i} (%i)n", i + MIN_STATE, (i+1)*10+(a[i]-MIN_STATE)*5, leftright [(i>(a [i]-MIN_STATE))\&amp;\&amp;((a [i]-MIN_STATE) != 3)], abovebelow    [((i+1)<=a[i])\&amp;\&amp;(a[i] != 4)], Z_A, y [Z_A][i], a [i]);
            if ((b [i] - MIN_STATE) == i)
                printf ("(%i) edge [loop] node {%i/%i} (%i)n", i + MIN_STATE, Z_B, y [Z_B][i], b [i]);
            else
                printf ("(%i) edge [bend angle=%i, bend %s,%s] node {%i/%i} (%i)n", i + MIN_STATE, (i+1)*25+(b[i]-MIN_STATE)*8, leftright [(i<=(b [i]-MIN_STATE)) \&amp;\&amp;((b [i]-MIN_STATE) != 3)], abovebelow [((i+MIN_STATE)>b [i])\&amp;\&amp;(b [i] != 4)], Z_B, y [Z_B][i], b [i]);
    }
    printf(";n");
    printf("\end{tikzpicture}n");
    printf("\end{center}n");
    printf("\end{document}n");

}

int main (int argc, char *argv []) {
    #define CREATE_NEW      0
    #define READ_CSV        1
    #define PRINT_TEX       0
    #define PRINT_CSV       1
    #define PRINT_NO_HELP   0
    #define PRINT_HELP      1

    int b [MAX_STATES];
    int a [MAX_STATES];
    int y [MAX_OUTPUTS][MAX_STATES];
    int argi;
    int createnew_readcsv = CREATE_NEW;
    int printraw_printtex_print_csv = PRINT_CSV;
    int printhelp = PRINT_NO_HELP;

    for (argi = 1;  argi < argc;  argi++) {
        if ((strcmp ("--create-new", argv [argi]) == 0) || (strcmp ("-n", argv [argi]) == 0))
            createnew_readcsv = CREATE_NEW;
        if ((strcmp ("--read-csv", argv [argi]) == 0) || (strcmp ("-s", argv [argi]) == 0))
            createnew_readcsv = READ_CSV;
        if ((strcmp ("--print-csv", argv [argi]) == 0) || (strcmp ("-c", argv [argi]) == 0))
            printraw_printtex_print_csv = PRINT_CSV;
        if ((strcmp ("--print-tex", argv [argi]) == 0) || (strcmp ("-t", argv [argi]) == 0))
            printraw_printtex_print_csv = PRINT_TEX;
        if ((strcmp ("--help", argv [argi]) == 0) || (strcmp ("-h", argv [argi]) == 0))
            printhelp = PRINT_HELP;
    }
    if (printhelp == PRINT_HELP) {
        printf ("--create-newn-nnn");
        printf ("--read-csvn-rnn");
        printf ("--print-csvn-cnn");
        printf ("--print-texn-tnn");
        printf ("--helpn-hnn");
        return 2;
    }
    if (createnew_readcsv == CREATE_NEW)
        createnew (a, b, y);
    else if (createnew_readcsv == READ_CSV);
        readcsv (a, b, y);
    if (printraw_printtex_print_csv == PRINT_TEX)
        printtex (a, b, y);
    else if (printraw_printtex_print_csv == PRINT_CSV)
        printcsv (a, b, y);
return 0;
}

Ach, ich glaube ich verstehe es

// a []

hat nur die Gr"osse MAX_STATES
Max States wurde zu klein deffiniert.

// Ja, jetzt geht es
// a [] und  b [] waren zu klein

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

#define MAX_SPECIAL_STATES      3
#define MAX_STATES              4
#define MIN_STATE               1
#define SPECIAL_STATE_1         1
#define SPECIAL_STATE_2         2
#define SPECIAL_STATE_3         3
#define MAX_INPUTS              2
#define MAX_OUTPUTS             2
#define TRUE                    1
#define FALSE                   0
#define Z_A                     0
#define Z_B                     1

void readcsv (int a [], int b [], int y [MAX_OUTPUTS][MAX_STATES]) {
    int i;
    int j;
    int i1, i2;
    int x1, x2;
    scanf ("Zustand,Eingabe,Ausgabe,Folgezustandn");

    for (i = 0;  i < (MAX_STATES*MAX_OUTPUTS) ;  ) {
        scanf ("%i,%i,%i,%in", \&amp;i1, \&amp;x1, \&amp;y [Z_A][i/2], \&amp;a [i]);
        i++;
        scanf ("%i,%i,%i,%in", \&amp;i2, \&amp;x2, \&amp;y [Z_B][i/2], \&amp;b [i]);
        i++;

/*
        if (x1 != Z_A) {
            printf ("Error - I/On");
            exit (1);
        }
        if (x2 != Z_B) {
            printf ("Error - I/On");
            exit (1);
        }
        if (i1 != (i+1)) {
            printf ("Error - I/On");
            exit (1);
        }
        if (i2 != (i+1)) {
            printf ("Error - I/On");
            exit (1);
        }*/
    }

return;
}

void printcsv (int a [], int b [], int y [MAX_OUTPUTS][MAX_STATES]) {
    int i;
    printf ("Zustand,Eingabe,Ausgabe,Folgezustandn");

    for (i = 0;  i < (MAX_STATES);  i++) {
        printf ("%i,%i,%i,%in", i+MIN_STATE, Z_A, y [Z_A][i], a [i]);
        printf ("%i,%i,%i,%in", i+MIN_STATE, Z_B, y [Z_B][i], b [i]);
    }

return;
}

void createnew (int a [], int b [], int y [MAX_OUTPUTS][MAX_STATES]) {
#define RAND_1      32
#define RAND_2      16
#define RAND_3      16
#define RAND_4      8

    time_t t;
    int i, j;
    int z [MAX_STATES][MAX_OUTPUTS];
    int flag;

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

    for (i = 0;  i < MAX_STATES;  i++) {
        z [i][Z_A] = i + MIN_STATE;
        z [i][Z_B] = i + MIN_STATE;
    }
    flag = 0;
    while (!flag) {
        for (i = 0;  i < MAX_STATES;  i++) {
            for (j = i + 1;  j < MAX_STATES;  j++) {
                if ((rand () % RAND_1) > RAND_2) {
                    t = z [j][Z_A];
                    z [j][Z_A] = z[i][Z_A];
                    z [i][Z_A] = t;
                }
            }
        }
        for (i = 0;  i < MAX_STATES;  i++) {
            for (j = i + 1;  j < MAX_STATES;  j++) {
                if ((rand () % RAND_3) < RAND_4) {
                    t = z [j][Z_B];
                    z [j][Z_B] = z[i][Z_B];
                    z [i][Z_B] = t;
                }
            }
        }
        flag = TRUE;
        for (i = 0;  i < MAX_STATES;  i++)
            if ((z[i][Z_A] == z[i][Z_B]) \&amp;\&amp; (z[i][Z_B] == i)) {
                flag = FALSE;
            }

    }
    for (i = 0;  i < MAX_STATES;  i++) {
        a [i] = z [Z_A][i];
        b [i] = z [Z_B][i];
        y [Z_A][i] = rand () % MAX_OUTPUTS;
        y [Z_B][i] = rand () % MAX_OUTPUTS;
    }

return;
}

void printtex (int a [], int b [], int y [MAX_OUTPUTS][MAX_STATES]) {
    int i, j;
    printf("\documentclass{article}n");
    printf("\usepackage[utf8]{inputenc}n");
    printf("\usepackage{pgf, tikz}n");
    printf("\usetikzlibrary{arrows , automata , positioning}n");
    printf("\begin{document}nn");

    printf("\begin{center}n");
    printf("\begin{tikzpicture}[>=stealth',shorten >=1pt,auto,node distance=2.5cm]n");
    printf("%Knotenn");

    printf("\node (1) [state, thick] {1};n");
    printf("\node (2) [state, thick, right of= 1] {2};n");
    printf("\node (3) [state, thick, above of= 2, right of= 2] {3};n");
    printf("\node (4) [state, thick, above of= 3, right of= 1] {4};nn");

    printf("%Verbindungenn");
    printf("\path[thick,->]n");

    char *leftright [] = {"left", "right"};
    char *abovebelow [] = {"above", "below"};

    for (i = 0;  i < MAX_STATES;  i++) {
            if ((a [i] - MIN_STATE) == i)
                printf ("(%i) edge [loop] node {%i/%i} (%i)n", i + MIN_STATE, Z_A, y [Z_A][i], a [i]);
            else
                printf ("(%i) edge [bend angle=%i, bend %s,%s] node {%i/%i} (%i)n", i + MIN_STATE, (i+1)*10+(a[i]-MIN_STATE)*5, leftright [(i>(a [i]-MIN_STATE))\&amp;\&amp;((a [i]-MIN_STATE) != 3)], abovebelow    [((i+1)<=a[i])\&amp;\&amp;(a[i] != 4)], Z_A, y [Z_A][i], a [i]);
            if ((b [i] - MIN_STATE) == i)
                printf ("(%i) edge [loop] node {%i/%i} (%i)n", i + MIN_STATE, Z_B, y [Z_B][i], b [i]);
            else
                printf ("(%i) edge [bend angle=%i, bend %s,%s] node {%i/%i} (%i)n", i + MIN_STATE, (i+1)*25+(b[i]-MIN_STATE)*8, leftright [(i<=(b [i]-MIN_STATE)) \&amp;\&amp;((b [i]-MIN_STATE) != 3)], abovebelow [((i+MIN_STATE)>b [i])\&amp;\&amp;(b [i] != 4)], Z_B, y [Z_B][i], b [i]);
    }
    printf(";n");
    printf("\end{tikzpicture}n");
    printf("\end{center}n");
    printf("\end{document}n");

}

int main (int argc, char *argv []) {
    #define CREATE_NEW      0
    #define READ_CSV        1
    #define PRINT_TEX       0
    #define PRINT_CSV       1
    #define PRINT_NO_HELP   0
    #define PRINT_HELP      1

    int b [MAX_STATES*MAX_OUTPUTS];
    int a [MAX_STATES*MAX_OUTPUTS];
    int y [MAX_OUTPUTS][MAX_STATES];
    int argi;
    int createnew_readcsv = CREATE_NEW;
    int printraw_printtex_print_csv = PRINT_CSV;
    int printhelp = PRINT_NO_HELP;

    for (argi = 1;  argi < argc;  argi++) {
        if ((strcmp ("--create-new", argv [argi]) == 0) || (strcmp ("-n", argv [argi]) == 0))
            createnew_readcsv = CREATE_NEW;
        if ((strcmp ("--read-csv", argv [argi]) == 0) || (strcmp ("-s", argv [argi]) == 0))
            createnew_readcsv = READ_CSV;
        if ((strcmp ("--print-csv", argv [argi]) == 0) || (strcmp ("-c", argv [argi]) == 0))
            printraw_printtex_print_csv = PRINT_CSV;
        if ((strcmp ("--print-tex", argv [argi]) == 0) || (strcmp ("-t", argv [argi]) == 0))
            printraw_printtex_print_csv = PRINT_TEX;
        if ((strcmp ("--help", argv [argi]) == 0) || (strcmp ("-h", argv [argi]) == 0))
            printhelp = PRINT_HELP;
    }
    if (printhelp == PRINT_HELP) {
        printf ("--create-newn-nnn");
        printf ("--read-csvn-rnn");
        printf ("--print-csvn-cnn");
        printf ("--print-texn-tnn");
        printf ("--helpn-hnn");
        return 2;
    }
    if (createnew_readcsv == CREATE_NEW)
        createnew (a, b, y);
    else if (createnew_readcsv == READ_CSV);
        readcsv (a, b, y);
    if (printraw_printtex_print_csv == PRINT_TEX)
        printtex (a, b, y);
    else if (printraw_printtex_print_csv == PRINT_CSV)
        printcsv (a, b, y);
return 0;
}

// Ja, jetzt geht es
// a [] und  b [] waren zu klein

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

#define MAX_SPECIAL_STATES      3
#define MAX_STATES              4
#define MIN_STATE               1
#define SPECIAL_STATE_1         1
#define SPECIAL_STATE_2         2
#define SPECIAL_STATE_3         3
#define MAX_INPUTS              2
#define MAX_OUTPUTS             2
#define TRUE                    1
#define FALSE                   0
#define Z_A                     0
#define Z_B                     1

void readcsv (int a [], int b [], int y [MAX_OUTPUTS][MAX_STATES]) {
    int i;
    int j;
    int i1, i2;
    int x1, x2;
    scanf ("Zustand,Eingabe,Ausgabe,Folgezustandn");

    for (i = 0;  i < (MAX_STATES*MAX_OUTPUTS) ;  ) {
        scanf ("%i,%i,%i,%in", \&amp;i1, \&amp;x1, \&amp;y [Z_A][i/2], \&amp;a [i]);
        i++;
        scanf ("%i,%i,%i,%in", \&amp;i2, \&amp;x2, \&amp;y [Z_B][i/2], \&amp;b [i]);
        i++;

/*
        if (x1 != Z_A) {
            printf ("Error - I/On");
            exit (1);
        }
        if (x2 != Z_B) {
            printf ("Error - I/On");
            exit (1);
        }
        if (i1 != (i+1)) {
            printf ("Error - I/On");
            exit (1);
        }
        if (i2 != (i+1)) {
            printf ("Error - I/On");
            exit (1);
        }*/
    }

return;
}

void printcsv (int a [], int b [], int y [MAX_OUTPUTS][MAX_STATES]) {
    int i;
    printf ("Zustand,Eingabe,Ausgabe,Folgezustandn");

    for (i = 0;  i < (MAX_STATES);  i++) {
        printf ("%i,%i,%i,%in", i+MIN_STATE, Z_A, y [Z_A][i], a [i]);
        printf ("%i,%i,%i,%in", i+MIN_STATE, Z_B, y [Z_B][i], b [i]);
    }

return;
}

void createnew (int a [], int b [], int y [MAX_OUTPUTS][MAX_STATES]) {
#define RAND_1      32
#define RAND_2      16
#define RAND_3      16
#define RAND_4      8

    time_t t;
    int i, j;
    int z [MAX_STATES][MAX_OUTPUTS];
    int flag;

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

    for (i = 0;  i < MAX_STATES;  i++) {
        z [i][Z_A] = i + MIN_STATE;
        z [i][Z_B] = i + MIN_STATE;
    }
    flag = 0;
    while (!flag) {
        for (i = 0;  i < MAX_STATES;  i++) {
            for (j = i + 1;  j < MAX_STATES;  j++) {
                if ((rand () % RAND_1) > RAND_2) {
                    t = z [j][Z_A];
                    z [j][Z_A] = z[i][Z_A];
                    z [i][Z_A] = t;
                }
            }
        }
        for (i = 0;  i < MAX_STATES;  i++) {
            for (j = i + 1;  j < MAX_STATES;  j++) {
                if ((rand () % RAND_3) < RAND_4) {
                    t = z [j][Z_B];
                    z [j][Z_B] = z[i][Z_B];
                    z [i][Z_B] = t;
                }
            }
        }
        flag = TRUE;
        for (i = 0;  i < MAX_STATES;  i++)
            if ((z[i][Z_A] == z[i][Z_B]) \&amp;\&amp; (z[i][Z_B] == i)) {
                flag = FALSE;
            }

    }
    for (i = 0;  i < MAX_STATES;  i++) {
        a [i] = z [Z_A][i];
        b [i] = z [Z_B][i];
        y [Z_A][i] = rand () % MAX_OUTPUTS;
        y [Z_B][i] = rand () % MAX_OUTPUTS;
    }

return;
}

void printtex (int a [], int b [], int y [MAX_OUTPUTS][MAX_STATES]) {
    int i, j;
    printf("\documentclass{article}n");
    printf("\usepackage[utf8]{inputenc}n");
    printf("\usepackage{pgf, tikz}n");
    printf("\usetikzlibrary{arrows , automata , positioning}n");
    printf("\begin{document}nn");

    printf("\begin{center}n");
    printf("\begin{tikzpicture}[>=stealth',shorten >=1pt,auto,node distance=2.5cm]n");
    printf("%Knotenn");

    printf("\node (1) [state, thick] {1};n");
    printf("\node (2) [state, thick, right of= 1] {2};n");
    printf("\node (3) [state, thick, above of= 2, right of= 2] {3};n");
    printf("\node (4) [state, thick, above of= 3, right of= 1] {4};nn");

    printf("%Verbindungenn");
    printf("\path[thick,->]n");

    char *leftright [] = {"left", "right"};
    char *abovebelow [] = {"above", "below"};

    for (i = 0;  i < MAX_STATES;  i++) {
            if ((a [i] - MIN_STATE) == i)
                printf ("(%i) edge [loop] node {%i/%i} (%i)n", i + MIN_STATE, Z_A, y [Z_A][i], a [i]);
            else
                printf ("(%i) edge [bend angle=%i, bend %s,%s] node {%i/%i} (%i)n", i + MIN_STATE, (i+1)*10+(a[i]-MIN_STATE)*5, leftright [(i>(a [i]-MIN_STATE))\&amp;\&amp;((a [i]-MIN_STATE) != 3)], abovebelow    [((i+1)<=a[i])\&amp;\&amp;(a[i] != 4)], Z_A, y [Z_A][i], a [i]);
            if ((b [i] - MIN_STATE) == i)
                printf ("(%i) edge [loop] node {%i/%i} (%i)n", i + MIN_STATE, Z_B, y [Z_B][i], b [i]);
            else
                printf ("(%i) edge [bend angle=%i, bend %s,%s] node {%i/%i} (%i)n", i + MIN_STATE, (i+1)*25+(b[i]-MIN_STATE)*8, leftright [(i<=(b [i]-MIN_STATE)) \&amp;\&amp;((b [i]-MIN_STATE) != 3)], abovebelow [((i+MIN_STATE)>b [i])\&amp;\&amp;(b [i] != 4)], Z_B, y [Z_B][i], b [i]);
    }
    printf(";n");
    printf("\end{tikzpicture}n");
    printf("\end{center}n");
    printf("\end{document}n");

}

int main (int argc, char *argv []) {
    #define CREATE_NEW      0
    #define READ_CSV        1
    #define PRINT_TEX       0
    #define PRINT_CSV       1
    #define PRINT_NO_HELP   0
    #define PRINT_HELP      1

    int b [MAX_STATES*MAX_OUTPUTS];
    int a [MAX_STATES*MAX_OUTPUTS];
    int y [MAX_OUTPUTS][MAX_STATES];
    int argi;
    int createnew_readcsv = CREATE_NEW;
    int printraw_printtex_print_csv = PRINT_CSV;
    int printhelp = PRINT_NO_HELP;

    for (argi = 1;  argi < argc;  argi++) {
        if ((strcmp ("--create-new", argv [argi]) == 0) || (strcmp ("-n", argv [argi]) == 0))
            createnew_readcsv = CREATE_NEW;
        if ((strcmp ("--read-csv", argv [argi]) == 0) || (strcmp ("-s", argv [argi]) == 0))
            createnew_readcsv = READ_CSV;
        if ((strcmp ("--print-csv", argv [argi]) == 0) || (strcmp ("-c", argv [argi]) == 0))
            printraw_printtex_print_csv = PRINT_CSV;
        if ((strcmp ("--print-tex", argv [argi]) == 0) || (strcmp ("-t", argv [argi]) == 0))
            printraw_printtex_print_csv = PRINT_TEX;
        if ((strcmp ("--help", argv [argi]) == 0) || (strcmp ("-h", argv [argi]) == 0))
            printhelp = PRINT_HELP;
    }
    if (printhelp == PRINT_HELP) {
        printf ("--create-newn-nnn");
        printf ("--read-csvn-rnn");
        printf ("--print-csvn-cnn");
        printf ("--print-texn-tnn");
        printf ("--helpn-hnn");
        return 2;
    }
    if (createnew_readcsv == CREATE_NEW)
        createnew (a, b, y);
    else if (createnew_readcsv == READ_CSV);
        readcsv (a, b, y);
    if (printraw_printtex_print_csv == PRINT_TEX)
        printtex (a, b, y);
    else if (printraw_printtex_print_csv == PRINT_CSV)
        printcsv (a, b, y);
return 0;
}

// OK, so funktioniert es jetzt auch mit Tabelle

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

#define MAX_SPECIAL_STATES      3
#define MAX_STATES              4
#define MIN_STATE               1
#define SPECIAL_STATE_1         1
#define SPECIAL_STATE_2         2
#define SPECIAL_STATE_3         3
#define MAX_INPUTS              2
#define MAX_OUTPUTS             2
#define TRUE                    1
#define FALSE                   0
#define Z_A                     0
#define Z_B                     1

void readcsv (int a [], int b [], int y [MAX_OUTPUTS][MAX_STATES]) {
    int i;
    int j;
    int i1, i2;
    int x1, x2;
    scanf ("Zustand,Eingabe,Ausgabe,Folgezustandn");

    for (i = 0;  i < (MAX_STATES*MAX_OUTPUTS) ;  ) {
        scanf ("%i,%i,%i,%in", \&amp;i1, \&amp;x1, \&amp;y [Z_A][i/2], \&amp;a [i]);
        i++;
        scanf ("%i,%i,%i,%in", \&amp;i2, \&amp;x2, \&amp;y [Z_B][i/2], \&amp;b [i]);
        i++;

/*
        if (x1 != Z_A) {
            printf ("Error - I/On");
            exit (1);
        }
        if (x2 != Z_B) {
            printf ("Error - I/On");
            exit (1);
        }
        if (i1 != (i+1)) {
            printf ("Error - I/On");
            exit (1);
        }
        if (i2 != (i+1)) {
            printf ("Error - I/On");
            exit (1);
        }*/
    }

return;
}

void printcsv (int a [], int b [], int y [MAX_OUTPUTS][MAX_STATES]) {
    int i;
    printf ("Zustand,Eingabe,Ausgabe,Folgezustandn");

    for (i = 0;  i < (MAX_STATES);  i++) {
        printf ("%i,%i,%i,%in", i+MIN_STATE, Z_A, y [Z_A][i], a [i]);
        printf ("%i,%i,%i,%in", i+MIN_STATE, Z_B, y [Z_B][i], b [i]);
    }

return;
}

void createnew (int a [], int b [], int y [MAX_OUTPUTS][MAX_STATES]) {
#define RAND_1      32
#define RAND_2      16
#define RAND_3      16
#define RAND_4      8

    time_t t;
    int i, j;
    int z [MAX_STATES][MAX_OUTPUTS];
    int flag;

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

    for (i = 0;  i < MAX_STATES;  i++) {
        z [Z_A][i] = i + MIN_STATE;
        z [Z_B][i] = i + MIN_STATE;
    }
    flag = 0;
    while (!flag) {
        for (i = 0;  i < MAX_STATES;  i++) {
            for (j = i + 1;  j < MAX_STATES;  j++) {
                if ((rand () % RAND_1) > RAND_2) {
                    t = z [Z_A][j];
                    z [Z_A][j] = z[i][Z_A];
                    z [Z_A][i] = t;
                }
            }
        }
        for (i = 0;  i < MAX_STATES;  i++) {
            for (j = i + 1;  j < MAX_STATES;  j++) {
                if ((rand () % RAND_3) < RAND_4) {
                    t = z [Z_B][j];
                    z [Z_B][j] = z[i][Z_B];
                    z [Z_B][i] = t;
                }
            }
        }
        flag = TRUE;
        for (i = 0;  i < MAX_STATES;  i++)
            if ((z[i][Z_A] == z[i][Z_B]) \&amp;\&amp; (z[i][Z_B] == i)) {
                flag = FALSE;
            }

    }
    for (i = 0;  i < MAX_STATES;  i++) {
        a [i] = z [Z_A][i];
        b [i] = z [Z_B][i];
        y [Z_A][i] = rand () % MAX_OUTPUTS;
        y [Z_B][i] = rand () % MAX_OUTPUTS;
    }

return;
}

void printtex (int a [], int b [], int y [MAX_OUTPUTS][MAX_STATES]) {
    int i, j;
    int codez = 8;
    printf("\documentclass{article}n");
    printf("\usepackage[utf8]{inputenc}n");
    printf("\usepackage{pgf, tikz}n");
    printf("\usetikzlibrary{arrows , automata , positioning}n");
    printf("\begin{document}nn");

    printf("\begin{center}n");
    printf("\begin{tikzpicture}[>=stealth',shorten >=1pt,auto,node distance=2.5cm]n");
    printf("%Knotenn");

    printf("\node (1) [state, thick] {1};n");
    printf("\node (2) [state, thick, right of= 1] {2};n");
    printf("\node (3) [state, thick, above of= 2, right of= 2] {3};n");
    printf("\node (4) [state, thick, above of= 3, right of= 1] {4};nn");

    printf("%Verbindungenn");
    printf("\path[thick,->]n");

    char *leftright [] = {"left", "right"};
    char *abovebelow [] = {"above", "below"};

    for (i = 0;  i < MAX_STATES;  i++) {
            if ((a [i] - MIN_STATE) == i)
                printf ("(%i) edge [loop] node {%i/%i} (%i)n", i + MIN_STATE, Z_A, y [Z_A][i], a [i]);
            else
                printf ("(%i) edge [bend angle=%i, bend %s,%s] node {%i/%i} (%i)n", i + MIN_STATE, (i+1)*10+(a[i]-MIN_STATE)*5, leftright [(i>(a [i]-MIN_STATE))\&amp;\&amp;((a [i]-MIN_STATE) != 3)], abovebelow    [((i+1)<=a[i])\&amp;\&amp;(a[i] != 4)], Z_A, y [Z_A][i], a [i]);
            if ((b [i] - MIN_STATE) == i)
                printf ("(%i) edge [loop] node {%i/%i} (%i)n", i + MIN_STATE, Z_B, y [Z_B][i], b [i]);
            else
                printf ("(%i) edge [bend angle=%i, bend %s,%s] node {%i/%i} (%i)n", i + MIN_STATE, (i+1)*25+(b[i]-MIN_STATE)*8, leftright [(i<=(b [i]-MIN_STATE)) \&amp;\&amp;((b [i]-MIN_STATE) != 3)], abovebelow [((i+MIN_STATE)>b [i])\&amp;\&amp;(b [i] != 4)], Z_B, y [Z_B][i], b [i]);
    }
    printf(";n");
    printf("\end{tikzpicture}n");
    printf("\end{center}n");

    printf ("\begin{center}n");
    printf ("\begin{tabular}{|l|l|l|l||l|l|l|l|}n");
   n");
    printf ("Zustand \&amp; Eingabe \&amp; Ausgabe \&amp; Folgezustand \&amp; \multicolumn{4}{|l|}{Codefolgezustand}n");
   n");
    printf BITTE IM PDF NACHGUCKEN
   n");
    for (i = 0;  i < MAX_STATES;  i++) {
        printf BITTE IM PDF NACHGUCKEN
        printf BITTE IM PDF NACHGUCKEN

    }
    printf ("\begin{tabular}n");
    printf ("\end{center}n");

    printf("\end{document}n");

}

int main (int argc, char *argv []) {
    #define CREATE_NEW      0
    #define READ_CSV        1
    #define PRINT_TEX       0
    #define PRINT_CSV       1
    #define PRINT_NO_HELP   0
    #define PRINT_HELP      1

    int b [MAX_STATES*MAX_OUTPUTS];
    int a [MAX_STATES*MAX_OUTPUTS];
    int y [MAX_OUTPUTS][MAX_STATES];
    int argi;
    int createnew_readcsv = CREATE_NEW;
    int printraw_printtex_print_csv = PRINT_CSV;
    int printhelp = PRINT_NO_HELP;

    for (argi = 1;  argi < argc;  argi++) {
        if ((strcmp ("--create-new", argv [argi]) == 0) || (strcmp ("-n", argv [argi]) == 0))
            createnew_readcsv = CREATE_NEW;
        if ((strcmp ("--read-csv", argv [argi]) == 0) || (strcmp ("-s", argv [argi]) == 0))
            createnew_readcsv = READ_CSV;
        if ((strcmp ("--print-csv", argv [argi]) == 0) || (strcmp ("-c", argv [argi]) == 0))
            printraw_printtex_print_csv = PRINT_CSV;
        if ((strcmp ("--print-tex", argv [argi]) == 0) || (strcmp ("-t", argv [argi]) == 0))
            printraw_printtex_print_csv = PRINT_TEX;
        if ((strcmp ("--help", argv [argi]) == 0) || (strcmp ("-h", argv [argi]) == 0))
            printhelp = PRINT_HELP;
    }
    if (printhelp == PRINT_HELP) {
        printf ("--create-newn-nnn");
        printf ("--read-csvn-rnn");
        printf ("--print-csvn-cnn");
        printf ("--print-texn-tnn");
        printf ("--helpn-hnn");
        return 2;
    }
    //if (createnew_readcsv == CREATE_NEW)
        createnew (a, b, y);
    //else if (createnew_readcsv == READ_CSV);
        //readcsv (a, b, y);
    if (printraw_printtex_print_csv == PRINT_TEX)
        printtex (a, b, y);
    else if (printraw_printtex_print_csv == PRINT_CSV)
        printcsv (a, b, y);
return 0;
}

// OK, so funktioniert es jetzt auch mit Tabelle

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

#define MAX_SPECIAL_STATES      3
#define MAX_STATES              4
#define MIN_STATE               1
#define SPECIAL_STATE_1         1
#define SPECIAL_STATE_2         2
#define SPECIAL_STATE_3         3
#define MAX_INPUTS              2
#define MAX_OUTPUTS             2
#define TRUE                    1
#define FALSE                   0
#define Z_A                     0
#define Z_B                     1

void readcsv (int a [], int b [], int y [MAX_OUTPUTS][MAX_STATES]) {
    int i;
    int j;
    int i1, i2;
    int x1, x2;
    scanf ("Zustand,Eingabe,Ausgabe,Folgezustandn");

    for (i = 0;  i < (MAX_STATES*MAX_OUTPUTS) ;  ) {
        scanf ("%i,%i,%i,%in", \&amp;i1, \&amp;x1, \&amp;y [Z_A][i/2], \&amp;a [i]);
        i++;
        scanf ("%i,%i,%i,%in", \&amp;i2, \&amp;x2, \&amp;y [Z_B][i/2], \&amp;b [i]);
        i++;

/*
        if (x1 != Z_A) {
            printf ("Error - I/On");
            exit (1);
        }
        if (x2 != Z_B) {
            printf ("Error - I/On");
            exit (1);
        }
        if (i1 != (i+1)) {
            printf ("Error - I/On");
            exit (1);
        }
        if (i2 != (i+1)) {
            printf ("Error - I/On");
            exit (1);
        }*/
    }

return;
}

void printcsv (int a [], int b [], int y [MAX_OUTPUTS][MAX_STATES]) {
    int i;
    printf ("Zustand,Eingabe,Ausgabe,Folgezustandn");

    for (i = 0;  i < (MAX_STATES);  i++) {
        printf ("%i,%i,%i,%in", i+MIN_STATE, Z_A, y [Z_A][i], a [i]);
        printf ("%i,%i,%i,%in", i+MIN_STATE, Z_B, y [Z_B][i], b [i]);
    }

return;
}

void createnew (int a [], int b [], int y [MAX_OUTPUTS][MAX_STATES]) {
#define RAND_1      32
#define RAND_2      16
#define RAND_3      16
#define RAND_4      8

    time_t t;
    int i, j;
    int z [MAX_STATES][MAX_OUTPUTS];
    int flag;

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

    for (i = 0;  i < MAX_STATES;  i++) {
        z [Z_A][i] = i + MIN_STATE;
        z [Z_B][i] = i + MIN_STATE;
    }
    flag = 0;
    while (!flag) {
        for (i = 0;  i < MAX_STATES;  i++) {
            for (j = i + 1;  j < MAX_STATES;  j++) {
                if ((rand () % RAND_1) > RAND_2) {
                    t = z [Z_A][j];
                    z [Z_A][j] = z[i][Z_A];
                    z [Z_A][i] = t;
                }
            }
        }
        for (i = 0;  i < MAX_STATES;  i++) {
            for (j = i + 1;  j < MAX_STATES;  j++) {
                if ((rand () % RAND_3) < RAND_4) {
                    t = z [Z_B][j];
                    z [Z_B][j] = z[i][Z_B];
                    z [Z_B][i] = t;
                }
            }
        }
        flag = TRUE;
        for (i = 0;  i < MAX_STATES;  i++)
            if ((z[i][Z_A] == z[i][Z_B]) \&amp;\&amp; (z[i][Z_B] == i)) {
                flag = FALSE;
            }

    }
    for (i = 0;  i < MAX_STATES;  i++) {
        a [i] = z [Z_A][i];
        b [i] = z [Z_B][i];
        y [Z_A][i] = rand () % MAX_OUTPUTS;
        y [Z_B][i] = rand () % MAX_OUTPUTS;
    }

return;
}

void printtex (int a [], int b [], int y [MAX_OUTPUTS][MAX_STATES]) {
    int i, j;
    int codez = 8;
    printf("\documentclass{article}n");
    printf("\usepackage[utf8]{inputenc}n");
    printf("\usepackage{pgf, tikz}n");
    printf("\usetikzlibrary{arrows , automata , positioning}n");
    printf("\begin{document}nn");

    printf("\begin{center}n");
    printf("\begin{tikzpicture}[>=stealth',shorten >=1pt,auto,node distance=2.5cm]n");
    printf("%Knotenn");

    printf("\node (1) [state, thick] {1};n");
    printf("\node (2) [state, thick, right of= 1] {2};n");
    printf("\node (3) [state, thick, above of= 2, right of= 2] {3};n");
    printf("\node (4) [state, thick, above of= 3, right of= 1] {4};nn");

    printf("%Verbindungenn");
    printf("\path[thick,->]n");

    char *leftright [] = {"left", "right"};
    char *abovebelow [] = {"above", "below"};

    for (i = 0;  i < MAX_STATES;  i++) {
            if ((a [i] - MIN_STATE) == i)
                printf ("(%i) edge [loop] node {%i/%i} (%i)n", i + MIN_STATE, Z_A, y [Z_A][i], a [i]);
            else
                printf ("(%i) edge [bend angle=%i, bend %s,%s] node {%i/%i} (%i)n", i + MIN_STATE, (i+1)*10+(a[i]-MIN_STATE)*5, leftright [(i>(a [i]-MIN_STATE))\&amp;\&amp;((a [i]-MIN_STATE) != 3)], abovebelow    [((i+1)<=a[i])\&amp;\&amp;(a[i] != 4)], Z_A, y [Z_A][i], a [i]);
            if ((b [i] - MIN_STATE) == i)
                printf ("(%i) edge [loop] node {%i/%i} (%i)n", i + MIN_STATE, Z_B, y [Z_B][i], b [i]);
            else
                printf ("(%i) edge [bend angle=%i, bend %s,%s] node {%i/%i} (%i)n", i + MIN_STATE, (i+1)*25+(b[i]-MIN_STATE)*8, leftright [(i<=(b [i]-MIN_STATE)) \&amp;\&amp;((b [i]-MIN_STATE) != 3)], abovebelow [((i+MIN_STATE)>b [i])\&amp;\&amp;(b [i] != 4)], Z_B, y [Z_B][i], b [i]);
    }
    printf(";n");
    printf("\end{tikzpicture}n");
    printf("\end{center}n");

    printf ("\begin{center}n");
    printf ("\begin{tabular}{|l|l|l|l||l|l|l|l|}n");
   n");
    printf ("Zustand \&amp; Eingabe \&amp; Ausgabe \&amp; Folgezustand \&amp; \multicolumn{4}{|l|}{Codefolgezustand}n");
   n");
    printf BITTE IM PDF NACHGUCKEN
   n");
    for (i = 0;  i < MAX_STATES;  i++) {
        printf BITTE IM PDF NACHGUCKEN
        printf BITTE IM PDF NACHGUCKEN

    }
    printf ("\begin{tabular}n");
    printf ("\end{center}n");

    printf("\end{document}n");

}

int main (int argc, char *argv []) {
    #define CREATE_NEW      0
    #define READ_CSV        1
    #define PRINT_TEX       0
    #define PRINT_CSV       1
    #define PRINT_NO_HELP   0
    #define PRINT_HELP      1

    int b [MAX_STATES*MAX_OUTPUTS];
    int a [MAX_STATES*MAX_OUTPUTS];
    int y [MAX_OUTPUTS][MAX_STATES];
    int argi;
    int createnew_readcsv = CREATE_NEW;
    int printraw_printtex_print_csv = PRINT_CSV;
    int printhelp = PRINT_NO_HELP;

    for (argi = 1;  argi < argc;  argi++) {
        if ((strcmp ("--create-new", argv [argi]) == 0) || (strcmp ("-n", argv [argi]) == 0))
            createnew_readcsv = CREATE_NEW;
        if ((strcmp ("--read-csv", argv [argi]) == 0) || (strcmp ("-s", argv [argi]) == 0))
            createnew_readcsv = READ_CSV;
        if ((strcmp ("--print-csv", argv [argi]) == 0) || (strcmp ("-c", argv [argi]) == 0))
            printraw_printtex_print_csv = PRINT_CSV;
        if ((strcmp ("--print-tex", argv [argi]) == 0) || (strcmp ("-t", argv [argi]) == 0))
            printraw_printtex_print_csv = PRINT_TEX;
        if ((strcmp ("--help", argv [argi]) == 0) || (strcmp ("-h", argv [argi]) == 0))
            printhelp = PRINT_HELP;
    }
    if (printhelp == PRINT_HELP) {
        printf ("--create-newn-nnn");
        printf ("--read-csvn-rnn");
        printf ("--print-csvn-cnn");
        printf ("--print-texn-tnn");
        printf ("--helpn-hnn");
        return 2;
    }
    //if (createnew_readcsv == CREATE_NEW)
        createnew (a, b, y);
    //else if (createnew_readcsv == READ_CSV);
        //readcsv (a, b, y);
    if (printraw_printtex_print_csv == PRINT_TEX)
        printtex (a, b, y);
    else if (printraw_printtex_print_csv == PRINT_CSV)
        printcsv (a, b, y);
return 0;
}

Image test-1

Image test2-1

Image test3-1

// Ich weiss, wo der Fehler war, es war ein ganz dummer Fehler - ubs sorry - und ich musste unter die Dusche. Ich musste drunter, jetzt geht es mir besser. Ich habe ihn gefunden

// Der Fehler war, dass ich i in der Schleife zwei Mal inkrementiert habe. Einerseits richtig, dass ich zwei Mal einlese, aber das tue ich so oder so. Ich habe ja zwei scanfs deswegen muss ich den Z"ahler nicht zwei Mal inkrementieren, weil das eine ist a das andere b. Sorry. Dummer Fehler. Das ist ein sehr dummer Fehler

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

#define MAX_SPECIAL_STATES      3
#define MAX_STATES              4
#define MIN_STATE               1
#define SPECIAL_STATE_1         1
#define SPECIAL_STATE_2         2
#define SPECIAL_STATE_3         3
#define MAX_INPUTS              2
#define MAX_OUTPUTS             2
#define TRUE                    1
#define FALSE                   0
#define Z_A                     0
#define Z_B                     1

void readcsv (int a [], int b [], int y [MAX_OUTPUTS][MAX_STATES]) {
    int i;
    int j;
    int i1, i2;
    int x1, x2;
    scanf ("Zustand,Eingabe,Ausgabe,Folgezustandn");

    for (i = 0;  i < MAX_STATES ;  i++) {
        scanf ("%i,%i,%i,%in", \&amp;i1, \&amp;x1, \&amp;y [Z_A][i], \&amp;a [i]);
        scanf ("%i,%i,%i,%in", \&amp;i2, \&amp;x2, \&amp;y [Z_B][i], \&amp;b [i]);

/*
        if (x1 != Z_A) {
            printf ("Error - I/On");
            exit (1);
        }
        if (x2 != Z_B) {
            printf ("Error - I/On");
            exit (1);
        }
        if (i1 != (i+1)) {
            printf ("Error - I/On");
            exit (1);
        }
        if (i2 != (i+1)) {
            printf ("Error - I/On");
            exit (1);
        }*/
    }

return;
}

void printcsv (int a [], int b [], int y [MAX_OUTPUTS][MAX_STATES]) {
    int i;
    printf ("Zustand,Eingabe,Ausgabe,Folgezustandn");

    for (i = 0;  i < (MAX_STATES);  i++) {
        printf ("%i,%i,%i,%in", i+MIN_STATE, Z_A, y [Z_A][i], a [i]);
        printf ("%i,%i,%i,%in", i+MIN_STATE, Z_B, y [Z_B][i], b [i]);
    }

return;
}

void createnew (int a [], int b [], int y [MAX_OUTPUTS][MAX_STATES]) {
#define RAND_1      32
#define RAND_2      16
#define RAND_3      16
#define RAND_4      8

    time_t t;
    int i, j;
    int z [MAX_STATES][MAX_OUTPUTS];
    int flag;

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

    for (i = 0;  i < MAX_STATES;  i++) {
        z [Z_A][i] = i + MIN_STATE;
        z [Z_B][i] = i + MIN_STATE;
    }
    flag = 0;
    while (!flag) {
        for (i = 0;  i < MAX_STATES;  i++) {
            for (j = i + 1;  j < MAX_STATES;  j++) {
                if ((rand () % RAND_1) > RAND_2) {
                    t = z [Z_A][j];
                    z [Z_A][j] = z[i][Z_A];
                    z [Z_A][i] = t;
                }
            }
        }
        for (i = 0;  i < MAX_STATES;  i++) {
            for (j = i + 1;  j < MAX_STATES;  j++) {
                if ((rand () % RAND_3) < RAND_4) {
                    t = z [Z_B][j];
                    z [Z_B][j] = z[i][Z_B];
                    z [Z_B][i] = t;
                }
            }
        }
        flag = TRUE;
        for (i = 0;  i < MAX_STATES;  i++)
            if ((z[i][Z_A] == z[i][Z_B]) \&amp;\&amp; (z[i][Z_B] == i)) {
                flag = FALSE;
            }

    }
    for (i = 0;  i < MAX_STATES;  i++) {
        a [i] = z [Z_A][i];
        b [i] = z [Z_B][i];
        y [Z_A][i] = rand () % MAX_OUTPUTS;
        y [Z_B][i] = rand () % MAX_OUTPUTS;
    }

return;
}

void printtex (int a [], int b [], int y [MAX_OUTPUTS][MAX_STATES]) {
    int i, j;
    int codez = 8;
    printf("\documentclass{article}n");
    printf("\usepackage[utf8]{inputenc}n");
    printf("\usepackage{pgf, tikz}n");
    printf("\usetikzlibrary{arrows , automata , positioning}n");
    printf("\begin{document}nn");

    printf("\begin{center}n");
    printf("\begin{tikzpicture}[>=stealth',shorten >=1pt,auto,node distance=2.5cm]n");
    printf("%Knotenn");

    printf("\node (1) [state, thick] {1};n");
    printf("\node (2) [state, thick, right of= 1] {2};n");
    printf("\node (3) [state, thick, above of= 2, right of= 2] {3};n");
    printf("\node (4) [state, thick, above of= 3, right of= 1] {4};nn");

    printf("%Verbindungenn");
    printf("\path[thick,->]n");

    char *leftright [] = {"left", "right"};
    char *abovebelow [] = {"above", "below"};

    for (i = 0;  i < MAX_STATES;  i++) {
            if ((a [i] - MIN_STATE) == i)
                printf ("(%i) edge [loop] node {%i/%i} (%i)n", i + MIN_STATE, Z_A, y [Z_A][i], a [i]);
            else
                printf ("(%i) edge [bend angle=%i, bend %s,%s] node {%i/%i} (%i)n", i + MIN_STATE, (i+1)*10+(a[i]-MIN_STATE)*5, leftright [(i>(a [i]-MIN_STATE))\&amp;\&amp;((a [i]-MIN_STATE) != 3)], abovebelow    [((i+1)<=a[i])\&amp;\&amp;(a[i] != 4)], Z_A, y [Z_A][i], a [i]);
            if ((b [i] - MIN_STATE) == i)
                printf ("(%i) edge [loop] node {%i/%i} (%i)n", i + MIN_STATE, Z_B, y [Z_B][i], b [i]);
            else
                printf ("(%i) edge [bend angle=%i, bend %s,%s] node {%i/%i} (%i)n", i + MIN_STATE, (i+1)*25+(b[i]-MIN_STATE)*8, leftright [(i<=(b [i]-MIN_STATE)) \&amp;\&amp;((b [i]-MIN_STATE) != 3)], abovebelow [((i+MIN_STATE)>b [i])\&amp;\&amp;(b [i] != 4)], Z_B, y [Z_B][i], b [i]);
    }
    printf(";n");
    printf("\end{tikzpicture}n");
    printf("\end{center}n");

    printf ("\begin{center}n");
    printf ("\begin{tabular}{|l|l|l|l||l|l|l|l|}n");
    n");
    printf ("Zustand \&amp; Eingabe \&amp; Ausgabe \&amp; Folgezustand \&amp; \multicolumn{4}{|l|}{Codefolgezustand}n");
    n");
    printf BITTE IM PDF NACHGUCKEN
    n");
    for (i = 0;  i < MAX_STATES;  i++) {
        printf BITTE IM PDF NACHGUCKEN
        printf BITTE IM PDF NACHGUCKEN

    }
    n");
    printf ("\end{tabular}n");
    printf ("\end{center}n");

    printf ("\begin{center}n");
    printf ("\begin{verbatim}n");
    for (i = MIN_STATE;  i < (MAX_STATES + MIN_STATE);  i++) {
        printf ("z%i+ := ", i);
        for (j = 0;  j < MAX_STATES;  j++) {
            if ( a [j] == i )
                printf ("z%i and x", a [j], y [j]);
            if ( b [j] == i )
                printf ("z%i and not x", b [j], y [j]);

            printf (" or ");
        }
        printf (" true;n");
    }
    printf ("end{verbatim}n");
    printf ("\end{center}n");

    printf("\end{document}n");

}

int main (int argc, char *argv []) {
    #define CREATE_NEW      0
    #define READ_CSV        1
    #define PRINT_TEX       0
    #define PRINT_CSV       1
    #define PRINT_NO_HELP   0
    #define PRINT_HELP      1

    int b [MAX_STATES];
    int a [MAX_STATES];
    int y [MAX_OUTPUTS][MAX_STATES];
    int argi;
    int createnew_readcsv = CREATE_NEW;
    int printraw_printtex_print_csv = PRINT_CSV;
    int printhelp = PRINT_NO_HELP;

    for (argi = 1;  argi < argc;  argi++) {
        if ((strcmp ("--create-new", argv [argi]) == 0) || (strcmp ("-n", argv [argi]) == 0))
            createnew_readcsv = CREATE_NEW;
        if ((strcmp ("--read-csv", argv [argi]) == 0) || (strcmp ("-s", argv [argi]) == 0))
            createnew_readcsv = READ_CSV;
        if ((strcmp ("--print-csv", argv [argi]) == 0) || (strcmp ("-c", argv [argi]) == 0))
            printraw_printtex_print_csv = PRINT_CSV;
        if ((strcmp ("--print-tex", argv [argi]) == 0) || (strcmp ("-t", argv [argi]) == 0))
            printraw_printtex_print_csv = PRINT_TEX;
        if ((strcmp ("--help", argv [argi]) == 0) || (strcmp ("-h", argv [argi]) == 0))
            printhelp = PRINT_HELP;
    }
    if (printhelp == PRINT_HELP) {
        printf ("--create-newn-nnn");
        printf ("--read-csvn-rnn");
        printf ("--print-csvn-cnn");
        printf ("--print-texn-tnn");
        printf ("--helpn-hnn");
        return 2;
    }
    //if (createnew_readcsv == CREATE_NEW)
        createnew (a, b, y);
    //else if (createnew_readcsv == READ_CSV);
        //readcsv (a, b, y);
    if (printraw_printtex_print_csv == PRINT_TEX)
        printtex (a, b, y);
    else if (printraw_printtex_print_csv == PRINT_CSV)
        printcsv (a, b, y);
return 0;
}

Also, der Fehler war, ich habe wild

z [Z_A][j] = z[Z_A][i];

// So stimmt es

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

#define MAX_SPECIAL_STATES      3
#define MAX_STATES              4
#define MIN_STATE               1
#define SPECIAL_STATE_1         1
#define SPECIAL_STATE_2         2
#define SPECIAL_STATE_3         3
#define MAX_INPUTS              2
#define MAX_OUTPUTS             2
#define TRUE                    1
#define FALSE                   0
#define Z_A                     0
#define Z_B                     1

void readcsv (int a [], int b [], int y [MAX_OUTPUTS][MAX_STATES]) {
    int i;
    int j;
    int i1, i2;
    int x1, x2;
    scanf ("Zustand,Eingabe,Ausgabe,Folgezustandn");

    for (i = 0;  i < MAX_STATES ;  i++) {
        scanf ("%i,%i,%i,%in", \&amp;i1, \&amp;x1, \&amp;y [Z_A][i], \&amp;a [i]);
        scanf ("%i,%i,%i,%in", \&amp;i2, \&amp;x2, \&amp;y [Z_B][i], \&amp;b [i]);

/*
        if (x1 != Z_A) {
            printf ("Error - I/On");
            exit (1);
        }
        if (x2 != Z_B) {
            printf ("Error - I/On");
            exit (1);
        }
        if (i1 != (i+1)) {
            printf ("Error - I/On");
            exit (1);
        }
        if (i2 != (i+1)) {
            printf ("Error - I/On");
            exit (1);
        }*/
    }

return;
}

void printcsv (int a [], int b [], int y [MAX_OUTPUTS][MAX_STATES]) {
    int i;
    printf ("Zustand,Eingabe,Ausgabe,Folgezustandn");

    for (i = 0;  i < (MAX_STATES);  i++) {
        printf ("%i,%i,%i,%in", i+MIN_STATE, Z_A, y [Z_A][i], a [i]);
        printf ("%i,%i,%i,%in", i+MIN_STATE, Z_B, y [Z_B][i], b [i]);
    }

return;
}

void createnew (int a [], int b [], int y [MAX_OUTPUTS][MAX_STATES]) {
#define RAND_1      32
#define RAND_2      16
#define RAND_3      16
#define RAND_4      8

    time_t t;
    int i, j;
    int z [MAX_STATES][MAX_OUTPUTS];
    int flag;

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

    for (i = 0;  i < MAX_STATES;  i++) {
        z [Z_A][i] = i + MIN_STATE;
        z [Z_B][i] = i + MIN_STATE;
    }
    flag = 0;
    while (!flag) {
        for (i = 0;  i < MAX_STATES;  i++) {
            for (j = i + 1;  j < MAX_STATES;  j++) {
                if ((rand () % RAND_1) > RAND_2) {
                    t = z [Z_A][j];
                    z [Z_A][j] = z[Z_A][i];
                    z [Z_A][i] = t;
                }
            }
        }
        for (i = 0;  i < MAX_STATES;  i++) {
            for (j = i + 1;  j < MAX_STATES;  j++) {
                if ((rand () % RAND_3) < RAND_4) {
                    t = z [Z_B][j];
                    z [Z_B][j] = z[Z_B][i];
                    z [Z_B][i] = t;
                }
            }
        }
        flag = TRUE;
        for (i = 0;  i < MAX_STATES;  i++)
            if ((z[Z_A][i] == z[Z_B][i]) \&amp;\&amp; (z[Z_B][i] == i)) {
                flag = FALSE;
            }

    }
    for (i = 0;  i < MAX_STATES;  i++) {
        a [i] = z [Z_A][i];
        b [i] = z [Z_B][i];
        y [Z_A][i] = rand () % MAX_OUTPUTS;
        y [Z_B][i] = rand () % MAX_OUTPUTS;
    }

return;
}

void printtex (int a [], int b [], int y [MAX_OUTPUTS][MAX_STATES]) {
    int i, j;
    int codez = 8;
    printf("\documentclass{article}n");
    printf("\usepackage[utf8]{inputenc}n");
    printf("\usepackage{pgf, tikz}n");
    printf("\usetikzlibrary{arrows , automata , positioning}n");
    printf("\begin{document}nn");

    printf("\begin{center}n");
    printf("\begin{tikzpicture}[>=stealth',shorten >=1pt,auto,node distance=2.5cm]n");
    printf("%Knotenn");

    printf("\node (1) [state, thick] {1};n");
    printf("\node (2) [state, thick, right of= 1] {2};n");
    printf("\node (3) [state, thick, above of= 2, right of= 2] {3};n");
    printf("\node (4) [state, thick, above of= 3, right of= 1] {4};nn");

    printf("%Verbindungenn");
    printf("\path[thick,->]n");

    char *leftright [] = {"left", "right"};
    char *abovebelow [] = {"above", "below"};

    for (i = 0;  i < MAX_STATES;  i++) {
            if ((a [i] - MIN_STATE) == i)
                printf ("(%i) edge [loop] node {%i/%i} (%i)n", i + MIN_STATE, Z_A, y [Z_A][i], a [i]);
            else
                printf ("(%i) edge [bend angle=%i, bend %s,%s] node {%i/%i} (%i)n", i + MIN_STATE, (i+1)*10+(a[i]-MIN_STATE)*5, leftright [(i>(a [i]-MIN_STATE))\&amp;\&amp;((a [i]-MIN_STATE) != 3)], abovebelow    [((i+1)<=a[i])\&amp;\&amp;(a[i] != 4)], Z_A, y [Z_A][i], a [i]);
            if ((b [i] - MIN_STATE) == i)
                printf ("(%i) edge [loop] node {%i/%i} (%i)n", i + MIN_STATE, Z_B, y [Z_B][i], b [i]);
            else
                printf ("(%i) edge [bend angle=%i, bend %s,%s] node {%i/%i} (%i)n", i + MIN_STATE, (i+1)*25+(b[i]-MIN_STATE)*8, leftright [(i<=(b [i]-MIN_STATE)) \&amp;\&amp;((b [i]-MIN_STATE) != 3)], abovebelow [((i+MIN_STATE)>b [i])\&amp;\&amp;(b [i] != 4)], Z_B, y [Z_B][i], b [i]);
    }
    printf(";n");
    printf("\end{tikzpicture}n");
    printf("\end{center}n");

    printf ("\begin{center}n");
    printf ("\begin{tabular}{|l|l|l|l||l|l|l|l|}n");
    n");
    printf ("Zustand \&amp; Eingabe \&amp; Ausgabe \&amp; Folgezustand \&amp; \multicolumn{4}{|l|}{Codefolgezustand}n");
    n");
    printf BITTE IM PDF NACHGUCKEN
    n");
    for (i = 0;  i < MAX_STATES;  i++) {
        printf BITTE IM PDF NACHGUCKEN
        printf BITTE IM PDF NACHGUCKEN

    }
    n");
    printf ("\end{tabular}n");
    printf ("\end{center}n");

    printf ("\begin{center}n");
    printf ("\begin{verbatim}n");
    for (i = MIN_STATE;  i < (MAX_STATES + MIN_STATE);  i++) {
        printf ("z%i+ := ", i);
        for (j = 0;  j < MAX_STATES;  j++) {
            if ( a [j] == i )
                printf ("z%i and x or ", a [j], y [j]);
            if ( b [j] == i )
                printf ("z%i and not x or ", b [j], y [j]);
        }
        printf (" true;n");
    }
    printf ("end{verbatim}n");
    printf ("\end{center}n");

    printf("\end{document}n");

}

int main (int argc, char *argv []) {
    #define CREATE_NEW      0
    #define READ_CSV        1
    #define PRINT_TEX       0
    #define PRINT_CSV       1
    #define PRINT_NO_HELP   0
    #define PRINT_HELP      1

    int b [MAX_STATES];
    int a [MAX_STATES];
    int y [MAX_OUTPUTS][MAX_STATES];
    int argi;
    int createnew_readcsv = CREATE_NEW;
    int printraw_printtex_print_csv = PRINT_CSV;
    int printhelp = PRINT_NO_HELP;

    for (argi = 1;  argi < argc;  argi++) {
        if ((strcmp ("--create-new", argv [argi]) == 0) || (strcmp ("-n", argv [argi]) == 0))
            createnew_readcsv = CREATE_NEW;
        if ((strcmp ("--read-csv", argv [argi]) == 0) || (strcmp ("-s", argv [argi]) == 0))
            createnew_readcsv = READ_CSV;
        if ((strcmp ("--print-csv", argv [argi]) == 0) || (strcmp ("-c", argv [argi]) == 0))
            printraw_printtex_print_csv = PRINT_CSV;
        if ((strcmp ("--print-tex", argv [argi]) == 0) || (strcmp ("-t", argv [argi]) == 0))
            printraw_printtex_print_csv = PRINT_TEX;
        if ((strcmp ("--help", argv [argi]) == 0) || (strcmp ("-h", argv [argi]) == 0))
            printhelp = PRINT_HELP;
    }
    if (printhelp == PRINT_HELP) {
        printf ("--create-newn-nnn");
        printf ("--read-csvn-rnn");
        printf ("--print-csvn-cnn");
        printf ("--print-texn-tnn");
        printf ("--helpn-hnn");
        return 2;
    }
    //if (createnew_readcsv == CREATE_NEW)
        createnew (a, b, y);
    //else if (createnew_readcsv == READ_CSV);
        //readcsv (a, b, y);
    if (printraw_printtex_print_csv == PRINT_TEX)
        printtex (a, b, y);
    else if (printraw_printtex_print_csv == PRINT_CSV)
        printcsv (a, b, y);
return 0;
}

Image test4-1

Image test5-1

Aber irgendetwas ist jetzt merkwürdig mit dem Sortieren - weil vorher hatte ich 2 Zustände pro Zustand. Das stimmt jetzt nicht mehr.

documentclass{article}
usepackage[utf8]{inputenc}
usepackage{pgf, tikz}
usetikzlibrary{arrows , automata , positioning}
begin{document}

begin{center}
begin{tikzpicture}[>=stealth',shorten >=1pt,auto,node distance=2.5cm]
%Knoten
node (1) [state, thick] {1};
node (2) [state, thick, right of= 1] {2};
node (3) [state, thick, above of= 2, right of= 2] {3};
node (4) [state, thick, above of= 3, right of= 1] {4};

%Verbindungen
path[thick,->]
(1) edge [bend angle=25, bend left,above] node {0/0} (4)
(1) edge [bend angle=49, bend left,above] node {1/0} (4)
(2) edge [bend angle=30, bend left,below] node {0/0} (3)
(2) edge [bend angle=66, bend right,above] node {1/0} (3)
(3) edge [bend angle=45, bend left,above] node {0/1} (4)
(3) edge [bend angle=83, bend left,below] node {1/0} (2)
(4) edge [bend angle=50, bend right,above] node {0/1} (3)
(4) edge [bend angle=100, bend left,below] node {1/1} (1)
;
end{tikzpicture}
end{center}
begin{center}
begin{tabular}{|l|l|l|l||l|l|l|l|}
hline
Zustand \&amp; Eingabe \&amp; Ausgabe \&amp; Folgezustand \&amp; multicolumn{4}{|l|}{Codefolgezustand}\
hline
\&amp; \&amp; \&amp; \&amp; verb"z3+" \&amp;  verb"z2+" \&amp;  verb"z1+" \&amp;  verb"z0+"\
hline
verb"z1" \&amp; verb"0" \&amp;  verb"0" \&amp; verb"z4" \&amp; verb"1"  \&amp; verb"0"  \&amp; verb"0"  \&amp; verb"0"\
verb"z1" \&amp; verb"1" \&amp;  verb"0" \&amp; verb"z4" \&amp; verb"1"  \&amp; verb"0"  \&amp; verb"0"  \&amp; verb"0"\
verb"z2" \&amp; verb"0" \&amp;  verb"0" \&amp; verb"z3" \&amp; verb"0"  \&amp; verb"1"  \&amp; verb"0"  \&amp; verb"0"\
verb"z2" \&amp; verb"1" \&amp;  verb"0" \&amp; verb"z3" \&amp; verb"0"  \&amp; verb"1"  \&amp; verb"0"  \&amp; verb"0"\
verb"z3" \&amp; verb"0" \&amp;  verb"1" \&amp; verb"z4" \&amp; verb"1"  \&amp; verb"0"  \&amp; verb"0"  \&amp; verb"0"\
verb"z3" \&amp; verb"1" \&amp;  verb"0" \&amp; verb"z2" \&amp; verb"0"  \&amp; verb"0"  \&amp; verb"1"  \&amp; verb"0"\
verb"z4" \&amp; verb"0" \&amp;  verb"1" \&amp; verb"z3" \&amp; verb"0"  \&amp; verb"1"  \&amp; verb"0"  \&amp; verb"0"\
verb"z4" \&amp; verb"1" \&amp;  verb"1" \&amp; verb"z1" \&amp; verb"0"  \&amp; verb"0"  \&amp; verb"0"  \&amp; verb"1"\
hline
end{tabular}
end{center}
begin{center}
begin{verbatim}
z1+ := z1 and not x or  true;
z2+ := z2 and not x or  true;
z3+ := z3 and x or z3 and not x or z3 and x or  true;
z4+ := z4 and x or z4 and not x or z4 and x or  true;
end{verbatim}
end{center}
end{document}

documentclass{article}
usepackage[utf8]{inputenc}
usepackage{pgf, tikz}
usetikzlibrary{arrows , automata , positioning}
begin{document}

begin{center}
begin{tikzpicture}[>=stealth',shorten >=1pt,auto,node distance=2.5cm]
%Knoten
node (1) [state, thick] {1};
node (2) [state, thick, right of= 1] {2};
node (3) [state, thick, above of= 2, right of= 2] {3};
node (4) [state, thick, above of= 3, right of= 1] {4};

%Verbindungen
path[thick,->]
(1) edge [bend angle=25, bend left,above] node {0/0} (4)
(1) edge [bend angle=33, bend right,above] node {1/1} (2)
(2) edge [bend angle=35, bend left,above] node {0/0} (4)
(2) edge [bend angle=50, bend left,below] node {1/0} (1)
(3) edge [bend angle=35, bend right,above] node {0/0} (2)
(3) edge [loop] node {1/0} (3)
(4) edge [bend angle=40, bend right,above] node {0/0} (1)
(4) edge [bend angle=116, bend left,below] node {1/1} (3)
;
end{tikzpicture}
end{center}
begin{center}
begin{tabular}{|l|l|l|l||l|l|l|l|}
hline
Zustand \&amp; Eingabe \&amp; Ausgabe \&amp; Folgezustand \&amp; multicolumn{4}{|l|}{Codefolgezustand}\
hline
\&amp; \&amp; \&amp; \&amp; verb"z3+" \&amp;  verb"z2+" \&amp;  verb"z1+" \&amp;  verb"z0+"\
hline
verb"z1" \&amp; verb"0" \&amp;  verb"0" \&amp; verb"z4" \&amp; verb"1"  \&amp; verb"0"  \&amp; verb"0"  \&amp; verb"0"\
verb"z1" \&amp; verb"1" \&amp;  verb"1" \&amp; verb"z2" \&amp; verb"0"  \&amp; verb"0"  \&amp; verb"1"  \&amp; verb"0"\
verb"z2" \&amp; verb"0" \&amp;  verb"0" \&amp; verb"z4" \&amp; verb"1"  \&amp; verb"0"  \&amp; verb"0"  \&amp; verb"0"\
verb"z2" \&amp; verb"1" \&amp;  verb"0" \&amp; verb"z1" \&amp; verb"0"  \&amp; verb"0"  \&amp; verb"0"  \&amp; verb"1"\
verb"z3" \&amp; verb"0" \&amp;  verb"0" \&amp; verb"z2" \&amp; verb"0"  \&amp; verb"0"  \&amp; verb"1"  \&amp; verb"0"\
verb"z3" \&amp; verb"1" \&amp;  verb"0" \&amp; verb"z3" \&amp; verb"0"  \&amp; verb"1"  \&amp; verb"0"  \&amp; verb"0"\
verb"z4" \&amp; verb"0" \&amp;  verb"0" \&amp; verb"z1" \&amp; verb"0"  \&amp; verb"0"  \&amp; verb"0"  \&amp; verb"1"\
verb"z4" \&amp; verb"1" \&amp;  verb"1" \&amp; verb"z3" \&amp; verb"0"  \&amp; verb"1"  \&amp; verb"0"  \&amp; verb"0"\
hline
end{tabular}
end{center}
begin{center}
begin{verbatim}
z1+ := z1 and not x or z1 and x or  true;
z2+ := z2 and not x or z2 and x or  true;
z3+ := z3 and not x or z3 and not x or  true;
z4+ := z4 and x or z4 and x or  true;
end{verbatim}
end{center}
end{document}

Image test6-1

Image test7-1

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



#define MAX_SPECIAL_STATES      3
#define MAX_STATES              4
#define MIN_STATE               1
#define SPECIAL_STATE_1         1
#define SPECIAL_STATE_2         2
#define SPECIAL_STATE_3         3
#define MAX_INPUTS              2
#define MAX_OUTPUTS             2
#define TRUE                    1
#define FALSE                   0
#define Z_A                     0
#define Z_B                     1


void readcsv (int a [], int b [], int y [MAX_OUTPUTS][MAX_STATES]) {
    int i;
    int j;
    int i1, i2;
    int x1, x2;
    scanf ("Zustand,Eingabe,Ausgabe,Folgezustandn");

    for (i = 0;  i < MAX_STATES ;  i++) {
        scanf ("%i,%i,%i,%in", \&amp;i1, \&amp;x1, \&amp;y [Z_A][i], \&amp;a [i]);
        scanf ("%i,%i,%i,%in", \&amp;i2, \&amp;x2, \&amp;y [Z_B][i], \&amp;b [i]);


/*
        if (x1 != Z_A) {
            printf ("Error - I/On");
            exit (1);
        }
        if (x2 != Z_B) {
            printf ("Error - I/On");
            exit (1);
        }
        if (i1 != (i+1)) {
            printf ("Error - I/On");
            exit (1);
        }
        if (i2 != (i+1)) {
            printf ("Error - I/On");
            exit (1);
        }*/
    }

return;
}


void printcsv (int a [], int b [], int y [MAX_OUTPUTS][MAX_STATES]) {
    int i;
    printf ("Zustand,Eingabe,Ausgabe,Folgezustandn");

    for (i = 0;  i < (MAX_STATES);  i++) {
        printf ("%i,%i,%i,%in", i+MIN_STATE, Z_A, y [Z_A][i], a [i]);
        printf ("%i,%i,%i,%in", i+MIN_STATE, Z_B, y [Z_B][i], b [i]);
    }

return;
}



void createnew (int a [], int b [], int y [MAX_OUTPUTS][MAX_STATES]) {
#define RAND_1      32
#define RAND_2      16
#define RAND_3      16
#define RAND_4      8

#define N_SORTS     8
    time_t t;
    int i, j;
    int flag;
    int s;

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


    for (i = 0;  i < MAX_STATES;  i++) {
        a [i] = i + MIN_STATE;
        b [i] = i + MIN_STATE;
    }
    flag = 0;
    for (s = 0;  s < N_SORTS;  s++)
        while (!flag) {
            for (i = 0;  i < MAX_STATES;  i++) {
                for (j = i + 1;  j < MAX_STATES;  j++) {
                    if ((rand () % RAND_1) > RAND_2) {
                        t = a [j];
                        a [j] = a [i];
                        a [i] = t;
                    }
                }
            }
            for (i = 0;  i < MAX_STATES;  i++) {
                for (j = i + 1;  j < MAX_STATES;  j++) {
                    if ((rand () % RAND_3) < RAND_4) {
                        t = b [j];
                        b [j] = b [i];
                        b [i] = t;
                    }
                }
            }
            flag = TRUE;
            for (i = 0;  i < MAX_STATES;  i++)
                if ((a [i] == b [i]) \&amp;\&amp; (b [i] == (i+MIN_STATE))) {
                    flag = FALSE;
                }

        }
    for (i = 0;  i < MAX_STATES;  i++) {
        y [Z_A][i] = rand () % MAX_OUTPUTS;
        y [Z_B][i] = rand () % MAX_OUTPUTS;
    }

return;
}



void printtex (int a [], int b [], int y [MAX_OUTPUTS][MAX_STATES]) {
    int i, j;
    int codez = 8;
    printf("\documentclass{article}n");
    printf("\usepackage[utf8]{inputenc}n");
    printf("\usepackage{pgf, tikz}n");
    printf("\usetikzlibrary{arrows , automata , positioning}n");
    printf("\begin{document}nn");


    printf("\begin{center}n");
    printf("\begin{tikzpicture}[>=stealth',shorten >=1pt,auto,node distance=2.5cm]n");
    printf("%Knotenn");

    printf("\node (1) [state, thick] {1};n");
    printf("\node (2) [state, thick, right of= 1] {2};n");
    printf("\node (3) [state, thick, above of= 2, right of= 2] {3};n");
    printf("\node (4) [state, thick, above of= 3, right of= 1] {4};nn");

    printf("%Verbindungenn");
    printf("\path[thick,->]n");



    char *leftright [] = {"left", "right"};
    char *abovebelow [] = {"above", "below"};

    for (i = 0;  i < MAX_STATES;  i++) {
            if ((a [i] - MIN_STATE) == i)
                printf ("(%i) edge [loop] node {%i/%i} (%i)n", i + MIN_STATE, Z_A, y [Z_A][i], a [i]);
            else
                printf ("(%i) edge [bend angle=%i, bend %s,%s] node {%i/%i} (%i)n", i + MIN_STATE, (i+1)*10+(a[i]-MIN_STATE)*5, leftright [(i>(a [i]-MIN_STATE))\&amp;\&amp;((a [i]-MIN_STATE) != 3)], abovebelow    [((i+1)<=a[i])\&amp;\&amp;(a[i] != 4)], Z_A, y [Z_A][i], a [i]);
            if ((b [i] - MIN_STATE) == i)
                printf ("(%i) edge [loop] node {%i/%i} (%i)n", i + MIN_STATE, Z_B, y [Z_B][i], b [i]);
            else
                printf ("(%i) edge [bend angle=%i, bend %s,%s] node {%i/%i} (%i)n", i + MIN_STATE, (i+1)*25+(b[i]-MIN_STATE)*8, leftright [(i<=(b [i]-MIN_STATE)) \&amp;\&amp;((b [i]-MIN_STATE) != 3)], abovebelow [((i+MIN_STATE)>b [i])\&amp;\&amp;(b [i] != 4)], Z_B, y [Z_B][i], b [i]);
    }
    printf(";n");
    printf("\end{tikzpicture}n");
    printf("\end{center}n");

    printf ("\begin{center}n");
    printf ("\begin{tabular}{|l|l|l|l||l|l|l|l|}n");
    n");
    printf ("Zustand \&amp; Eingabe \&amp; Ausgabe \&amp; Folgezustand \&amp; \multicolumn{4}{|l|}{Codefolgezustand}n");
    n");
    printf BITTE IM PDF NACHGUCKEN
    n");
    for (i = 0;  i < MAX_STATES;  i++) {
        printf BITTE IM PDF NACHGUCKEN
        printf BITTE IM PDF NACHGUCKEN

    }
    n");
    printf ("\end{tabular}n");
    printf ("\end{center}n");


    printf ("\begin{center}n");
    printf ("\begin{verbatim}n");
    for (i = MIN_STATE;  i < (MAX_STATES + MIN_STATE);  i++) {
        printf ("z%i+ := ", i);
        for (j = 0;  j < MAX_STATES;  j++) {
            if ( a [j] == i )
                printf ("z%i and x or ", a [j], y [j]);
            if ( b [j] == i )
                printf ("z%i and not x or ", b [j], y [j]);
        }
        printf (" true;n");
    }
    printf ("end{verbatim}n");
    printf ("\end{center}n");

    printf("\end{document}n");

}

int main (int argc, char *argv []) {
    #define CREATE_NEW      0
    #define READ_CSV        1
    #define PRINT_TEX       0
    #define PRINT_CSV       1
    #define PRINT_NO_HELP   0
    #define PRINT_HELP      1

    int b [MAX_STATES];
    int a [MAX_STATES];
    int y [MAX_OUTPUTS][MAX_STATES];
    int argi;
    int createnew_readcsv = CREATE_NEW;
    int printraw_printtex_print_csv = PRINT_CSV;
    int printhelp = PRINT_NO_HELP;

    for (argi = 1;  argi < argc;  argi++) {
        if ((strcmp ("--create-new", argv [argi]) == 0) || (strcmp ("-n", argv [argi]) == 0))
            createnew_readcsv = CREATE_NEW;
        if ((strcmp ("--read-csv", argv [argi]) == 0) || (strcmp ("-s", argv [argi]) == 0))
            createnew_readcsv = READ_CSV;
        if ((strcmp ("--print-csv", argv [argi]) == 0) || (strcmp ("-c", argv [argi]) == 0))
            printraw_printtex_print_csv = PRINT_CSV;
        if ((strcmp ("--print-tex", argv [argi]) == 0) || (strcmp ("-t", argv [argi]) == 0))
            printraw_printtex_print_csv = PRINT_TEX;
        if ((strcmp ("--help", argv [argi]) == 0) || (strcmp ("-h", argv [argi]) == 0))
            printhelp = PRINT_HELP;
    }
    if (printhelp == PRINT_HELP) {
        printf ("--create-newn-nnn");
        printf ("--read-csvn-rnn");
        printf ("--print-csvn-cnn");
        printf ("--print-texn-tnn");
        printf ("--helpn-hnn");
        return 2;
    }
    //if (createnew_readcsv == CREATE_NEW)
        createnew (a, b, y);
    //else if (createnew_readcsv == READ_CSV);
        //readcsv (a, b, y);
    if (printraw_printtex_print_csv == PRINT_TEX)
        printtex (a, b, y);
    else if (printraw_printtex_print_csv == PRINT_CSV)
        printcsv (a, b, y);
return 0;
}
[/code}</CODE>}

\section{ Re: Aufgaben und "Ubungen, }
Also, es tut jetzt bestens

\includegraphics[width=\textwidth]{./david4/2024-02-08/test2-1.jpg}

\includegraphics[width=\textwidth]{./david4/2024-02-08/test3-1.jpg}

\includegraphics[width=\textwidth]{./david4/2024-02-08/test4-1.jpg}

\includegraphics[width=\textwidth]{./david4/2024-02-08/test5-1.jpg}

\includegraphics[width=\textwidth]{./david4/2024-02-08/test6-1.jpg}

\includegraphics[width=\textwidth]{./david4/2024-02-08/test7-1.jpg}

\includegraphics[width=\textwidth]{./david4/2024-02-08/test8-1.jpg}

\includegraphics[width=\textwidth]{./david4/2024-02-08/test9-1.jpg}

Jetzt mit dem besseren Programm "ube ich einen Automat.

Halt, da ist ein Fehler, in der Formel, sehe ich gerade, nicht im Zustandsdiagramm.

\begin{verbatim}
// Jetzt ist richtig

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



#define MAX_SPECIAL_STATES      3
#define MAX_STATES              4
#define MIN_STATE               1
#define SPECIAL_STATE_1         1
#define SPECIAL_STATE_2         2
#define SPECIAL_STATE_3         3
#define MAX_INPUTS              2
#define MAX_OUTPUTS             2
#define TRUE                    1
#define FALSE                   0
#define Z_A                     0
#define Z_B                     1


void readcsv (int a [], int b [], int y [MAX_OUTPUTS][MAX_STATES]) {
    int i;
    int j;
    int i1, i2;
    int x1, x2;
    scanf ("Zustand,Eingabe,Ausgabe,Folgezustandn");

    for (i = 0;  i < MAX_STATES ;  i++) {
        scanf ("%i,%i,%i,%in", \&amp;i1, \&amp;x1, \&amp;y [Z_A][i], \&amp;a [i]);
        scanf ("%i,%i,%i,%in", \&amp;i2, \&amp;x2, \&amp;y [Z_B][i], \&amp;b [i]);


/*
        if (x1 != Z_A) {
            printf ("Error - I/On");
            exit (1);
        }
        if (x2 != Z_B) {
            printf ("Error - I/On");
            exit (1);
        }
        if (i1 != (i+1)) {
            printf ("Error - I/On");
            exit (1);
        }
        if (i2 != (i+1)) {
            printf ("Error - I/On");
            exit (1);
        }*/
    }

return;
}


void printcsv (int a [], int b [], int y [MAX_OUTPUTS][MAX_STATES]) {
    int i;
    printf ("Zustand,Eingabe,Ausgabe,Folgezustandn");

    for (i = 0;  i < (MAX_STATES);  i++) {
        printf ("%i,%i,%i,%in", i+MIN_STATE, Z_A, y [Z_A][i], a [i]);
        printf ("%i,%i,%i,%in", i+MIN_STATE, Z_B, y [Z_B][i], b [i]);
    }

return;
}



void createnew (int a [], int b [], int y [MAX_OUTPUTS][MAX_STATES]) {
#define RAND_1      32
#define RAND_2      16
#define RAND_3      16
#define RAND_4      8

#define N_SORTS     8
    time_t t;
    int i, j;
    int flag;
    int s;

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


    for (i = 0;  i < MAX_STATES;  i++) {
        a [i] = i + MIN_STATE;
        b [i] = i + MIN_STATE;
    }
    flag = 0;
    for (s = 0;  s < N_SORTS;  s++)
        while (!flag) {
            for (i = 0;  i < MAX_STATES;  i++) {
                for (j = i + 1;  j < MAX_STATES;  j++) {
                    if ((rand () % RAND_1) > RAND_2) {
                        t = a [j];
                        a [j] = a [i];
                        a [i] = t;
                    }
                }
            }
            for (i = 0;  i < MAX_STATES;  i++) {
                for (j = i + 1;  j < MAX_STATES;  j++) {
                    if ((rand () % RAND_3) < RAND_4) {
                        t = b [j];
                        b [j] = b [i];
                        b [i] = t;
                    }
                }
            }
            flag = TRUE;
            for (i = 0;  i < MAX_STATES;  i++)
                if ((a [i] == b [i]) \&amp;\&amp; (b [i] == (i+MIN_STATE))) {
                    flag = FALSE;
                }

        }
    for (i = 0;  i < MAX_STATES;  i++) {
        y [Z_A][i] = rand () % MAX_OUTPUTS;
        y [Z_B][i] = rand () % MAX_OUTPUTS;
    }

return;
}



void printtex (int a [], int b [], int y [MAX_OUTPUTS][MAX_STATES]) {
    int i, j;
    int codez = 8;
    printf("\documentclass{article}n");
    printf("\usepackage[utf8]{inputenc}n");
    printf("\usepackage{pgf, tikz}n");
    printf("\usetikzlibrary{arrows , automata , positioning}n");
    printf("\begin{document}nn");


    printf("\begin{center}n");
    printf("\begin{tikzpicture}[>=stealth',shorten >=1pt,auto,node distance=2.5cm]n");
    printf("%Knotenn");

    printf("\node (1) [state, thick] {1};n");
    printf("\node (2) [state, thick, right of= 1] {2};n");
    printf("\node (3) [state, thick, above of= 2, right of= 2] {3};n");
    printf("\node (4) [state, thick, above of= 3, right of= 1] {4};nn");

    printf("%Verbindungenn");
    printf("\path[thick,->]n");



    char *leftright [] = {"left", "right"};
    char *abovebelow [] = {"above", "below"};

    for (i = 0;  i < MAX_STATES;  i++) {
            if ((a [i] - MIN_STATE) == i)
                printf ("(%i) edge [loop] node {%i/%i} (%i)n", i + MIN_STATE, Z_A, y [Z_A][i], a [i]);
            else
                printf ("(%i) edge [bend angle=%i, bend %s,%s] node {%i/%i} (%i)n", i + MIN_STATE, (i+1)*10+(a[i]-MIN_STATE)*5, leftright [(i>(a [i]-MIN_STATE))\&amp;\&amp;((a [i]-MIN_STATE) != 3)], abovebelow    [((i+1)<=a[i])\&amp;\&amp;(a[i] != 4)], Z_A, y [Z_A][i], a [i]);
            if ((b [i] - MIN_STATE) == i)
                printf ("(%i) edge [loop] node {%i/%i} (%i)n", i + MIN_STATE, Z_B, y [Z_B][i], b [i]);
            else
                printf ("(%i) edge [bend angle=%i, bend %s,%s] node {%i/%i} (%i)n", i + MIN_STATE, (i+1)*25+(b[i]-MIN_STATE)*8, leftright [(i<=(b [i]-MIN_STATE)) \&amp;\&amp;((b [i]-MIN_STATE) != 3)], abovebelow [((i+MIN_STATE)>b [i])\&amp;\&amp;(b [i] != 4)], Z_B, y [Z_B][i], b [i]);
    }
    printf(";n");
    printf("\end{tikzpicture}n");
    printf("\end{center}n");

    printf ("\begin{center}n");
    printf ("\begin{tabular}{|l|l|l|l||l|l|l|l|}n");
    n");
    printf ("Zustand \&amp; Eingabe \&amp; Ausgabe \&amp; Folgezustand \&amp; \multicolumn{4}{|l|}{Codefolgezustand}n");
    n");
    printf BITTE IM PDF NACHGUCKEN
    n");
    for (i = 0;  i < MAX_STATES;  i++) {
        printf BITTE IM PDF NACHGUCKEN
        printf BITTE IM PDF NACHGUCKEN

    }
    n");
    printf ("\end{tabular}n");
    printf ("\end{center}n");


    printf ("\begin{center}n");
    printf ("\begin{verbatim}n");
    for (i = MIN_STATE;  i < (MAX_STATES + MIN_STATE);  i++) {
        printf ("z%i+ := ", i);
        for (j = 0;  j < MAX_STATES;  j++) {
            if ( a [j] == i )
                printf ("z%i and x or ", j+MIN_STATE, y [j]);
            if ( b [j] == i )
                printf ("z%i and not x or ", j+MIN_STATE, y [j]);
        }
        printf (" true;n");
    }
    printf ("end{verbatim}n");
    printf ("\end{center}n");

    printf("\end{document}n");

}

int main (int argc, char *argv []) {
    #define CREATE_NEW      0
    #define READ_CSV        1
    #define PRINT_TEX       0
    #define PRINT_CSV       1
    #define PRINT_NO_HELP   0
    #define PRINT_HELP      1

    int b [MAX_STATES];
    int a [MAX_STATES];
    int y [MAX_OUTPUTS][MAX_STATES];
    int argi;
    int createnew_readcsv = CREATE_NEW;
    int printraw_printtex_print_csv = PRINT_CSV;
    int printhelp = PRINT_NO_HELP;

    for (argi = 1;  argi < argc;  argi++) {
        if ((strcmp ("--create-new", argv [argi]) == 0) || (strcmp ("-n", argv [argi]) == 0))
            createnew_readcsv = CREATE_NEW;
        if ((strcmp ("--read-csv", argv [argi]) == 0) || (strcmp ("-s", argv [argi]) == 0))
            createnew_readcsv = READ_CSV;
        if ((strcmp ("--print-csv", argv [argi]) == 0) || (strcmp ("-c", argv [argi]) == 0))
            printraw_printtex_print_csv = PRINT_CSV;
        if ((strcmp ("--print-tex", argv [argi]) == 0) || (strcmp ("-t", argv [argi]) == 0))
            printraw_printtex_print_csv = PRINT_TEX;
        if ((strcmp ("--help", argv [argi]) == 0) || (strcmp ("-h", argv [argi]) == 0))
            printhelp = PRINT_HELP;
    }
    if (printhelp == PRINT_HELP) {
        printf ("--create-newn-nnn");
        printf ("--read-csvn-rnn");
        printf ("--print-csvn-cnn");
        printf ("--print-texn-tnn");
        printf ("--helpn-hnn");
        return 2;
    }
    //if (createnew_readcsv == CREATE_NEW)
        createnew (a, b, y);
    //else if (createnew_readcsv == READ_CSV);
        //readcsv (a, b, y);
    if (printraw_printtex_print_csv == PRINT_TEX)
        printtex (a, b, y);
    else if (printraw_printtex_print_csv == PRINT_CSV)
        printcsv (a, b, y);
return 0;
}

Image test10-1

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



#define MAX_SPECIAL_STATES      3
#define MAX_STATES              4
#define MIN_STATE               1
#define SPECIAL_STATE_1         1
#define SPECIAL_STATE_2         2
#define SPECIAL_STATE_3         3
#define MAX_INPUTS              2
#define MAX_OUTPUTS             2
#define TRUE                    1
#define FALSE                   0
#define Z_A                     0
#define Z_B                     1


void readcsv (int a [], int b [], int y [MAX_OUTPUTS][MAX_STATES]) {
    int i;
    int j;
    int i1, i2;
    int x1, x2;
    scanf ("Zustand,Eingabe,Ausgabe,Folgezustandn");

    for (i = 0;  i < MAX_STATES ;  i++) {
        scanf ("%i,%i,%i,%in", \&amp;i1, \&amp;x1, \&amp;y [Z_A][i], \&amp;a [i]);
        scanf ("%i,%i,%i,%in", \&amp;i2, \&amp;x2, \&amp;y [Z_B][i], \&amp;b [i]);
        printf ("%i,%i,%i,%in", i1, x1, y [Z_A][i], a [i]);
        printf ("%i,%i,%i,%in", i2, x2, y [Z_B][i], b [i]);


/*
        if (x1 != Z_A) {
            printf ("Error - I/On");
            exit (1);
        }
        if (x2 != Z_B) {
            printf ("Error - I/On");
            exit (1);
        }
        if (i1 != (i+1)) {
            printf ("Error - I/On");
            exit (1);
        }
        if (i2 != (i+1)) {
            printf ("Error - I/On");
            exit (1);
        }*/
    }

return;
}


void printcsv (int a [], int b [], int y [MAX_OUTPUTS][MAX_STATES]) {
    int i;
    printf ("Zustand,Eingabe,Ausgabe,Folgezustandn");

    for (i = 0;  i < (MAX_STATES);  i++) {
        printf ("%i,%i,%i,%in", i+MIN_STATE, Z_A, y [Z_A][i], a [i]);
        printf ("%i,%i,%i,%in", i+MIN_STATE, Z_B, y [Z_B][i], b [i]);
    }

return;
}



void createnew (int a [], int b [], int y [MAX_OUTPUTS][MAX_STATES]) {
#define RAND_1      32
#define RAND_2      16
#define RAND_3      16
#define RAND_4      8

#define N_SORTS     8
    time_t t;
    int i, j;
    int flag;
    int s;

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


    for (i = 0;  i < MAX_STATES;  i++) {
        a [i] = i + MIN_STATE;
        b [i] = i + MIN_STATE;
    }
    flag = 0;
    for (s = 0;  s < N_SORTS;  s++)
        while (!flag) {
            for (i = 0;  i < MAX_STATES;  i++) {
                for (j = i + 1;  j < MAX_STATES;  j++) {
                    if ((rand () % RAND_1) > RAND_2) {
                        t = a [j];
                        a [j] = a [i];
                        a [i] = t;
                    }
                }
            }
            for (i = 0;  i < MAX_STATES;  i++) {
                for (j = i + 1;  j < MAX_STATES;  j++) {
                    if ((rand () % RAND_3) < RAND_4) {
                        t = b [j];
                        b [j] = b [i];
                        b [i] = t;
                    }
                }
            }
            flag = TRUE;
            for (i = 0;  i < MAX_STATES;  i++)
                if ((a [i] == b [i]) \&amp;\&amp; (b [i] == (i+MIN_STATE))) {
                    flag = FALSE;
                }

        }
    for (i = 0;  i < MAX_STATES;  i++) {
        y [Z_A][i] = rand () % MAX_OUTPUTS;
        y [Z_B][i] = rand () % MAX_OUTPUTS;
    }

return;
}



void printtex (int a [], int b [], int y [MAX_OUTPUTS][MAX_STATES]) {
    int i, j;
    int codez = 8;
    printf("\documentclass{article}n");
    printf("\usepackage[utf8]{inputenc}n");
    printf("\usepackage{pgf, tikz}n");
    printf("\usetikzlibrary{arrows , automata , positioning}n");
    printf("\begin{document}nn");


    printf("\begin{center}n");
    printf("\begin{tikzpicture}[>=stealth',shorten >=1pt,auto,node distance=2.5cm]n");
    printf("%Knotenn");

    printf("\node (1) [state, thick] {1};n");
    printf("\node (2) [state, thick, right of= 1] {2};n");
    printf("\node (3) [state, thick, above of= 2, right of= 2] {3};n");
    printf("\node (4) [state, thick, above of= 3, right of= 1] {4};nn");

    printf("%Verbindungenn");
    printf("\path[thick,->]n");



    char *leftright [] = {"left", "right"};
    char *abovebelow [] = {"above", "below"};

    for (i = 0;  i < MAX_STATES;  i++) {
            if ((a [i] - MIN_STATE) == i)
                printf ("(%i) edge [loop] node {%i/%i} (%i)n", i + MIN_STATE, Z_A, y [Z_A][i], a [i]);
            else
                printf ("(%i) edge [bend angle=%i, bend %s,%s] node {%i/%i} (%i)n", i + MIN_STATE, (i+1)*10+(a[i]-MIN_STATE)*5, leftright [(i>(a [i]-MIN_STATE))\&amp;\&amp;((a [i]-MIN_STATE) != 3)], abovebelow    [((i+1)<=a[i])\&amp;\&amp;(a[i] != 4)], Z_A, y [Z_A][i], a [i]);
            if ((b [i] - MIN_STATE) == i)
                printf ("(%i) edge [loop] node {%i/%i} (%i)n", i + MIN_STATE, Z_B, y [Z_B][i], b [i]);
            else
                printf ("(%i) edge [bend angle=%i, bend %s,%s] node {%i/%i} (%i)n", i + MIN_STATE, (i+1)*25+(b[i]-MIN_STATE)*8, leftright [(i<=(b [i]-MIN_STATE)) \&amp;\&amp;((b [i]-MIN_STATE) != 3)], abovebelow [((i+MIN_STATE)>b [i])\&amp;\&amp;(b [i] != 4)], Z_B, y [Z_B][i], b [i]);
    }
    printf(";n");
    printf("\end{tikzpicture}n");
    printf("\end{center}n");

    printf ("\begin{center}n");
    printf ("\begin{tabular}{|l|l|l|l||l|l|l|l|}n");
    n");
    printf ("Zustand \&amp; Eingabe \&amp; Ausgabe \&amp; Folgezustand \&amp; \multicolumn{4}{|l|}{Codefolgezustand}n");
    n");
    printf BITTE IM PDF NACHGUCKEN
    n");
    for (i = 0;  i < MAX_STATES;  i++) {
        printf BITTE IM PDF NACHGUCKEN
        printf BITTE IM PDF NACHGUCKEN

    }
    n");
    printf ("\end{tabular}n");
    printf ("\end{center}n");


    printf ("\begin{center}n");
    printf ("\begin{verbatim}n");
    for (i = MIN_STATE;  i < (MAX_STATES + MIN_STATE);  i++) {
        printf ("z%i+ := ", i);
        for (j = 0;  j < MAX_STATES;  j++) {
            if ( a [j] == i )
                printf ("z%i and x or ", j+MIN_STATE, y [j]);
            if ( b [j] == i )
                printf ("z%i and not x or ", j+MIN_STATE, y [j]);
        }
        printf (" true;n");
    }
    printf ("end{verbatim}n");
    printf ("\end{center}n");

    printf("\end{document}n");

}

int main (int argc, char *argv []) {
    #define CREATE_NEW      0
    #define READ_CSV        1
    #define PRINT_TEX       0
    #define PRINT_CSV       1
    #define PRINT_NO_HELP   0
    #define PRINT_HELP      1

    int b [MAX_STATES];
    int a [MAX_STATES];
    int y [MAX_OUTPUTS][MAX_STATES];
    int argi;
    int createnew_readcsv = CREATE_NEW;
    int printraw_printtex_print_csv = PRINT_CSV;
    int printhelp = PRINT_NO_HELP;

    for (argi = 1;  argi < argc;  argi++) {
        if ((strcmp ("--create-new", argv [argi]) == 0) || (strcmp ("-n", argv [argi]) == 0))
            createnew_readcsv = CREATE_NEW;
        if ((strcmp ("--read-csv", argv [argi]) == 0) || (strcmp ("-s", argv [argi]) == 0))
            createnew_readcsv = READ_CSV;
        if ((strcmp ("--print-csv", argv [argi]) == 0) || (strcmp ("-c", argv [argi]) == 0))
            printraw_printtex_print_csv = PRINT_CSV;
        if ((strcmp ("--print-tex", argv [argi]) == 0) || (strcmp ("-t", argv [argi]) == 0))
                printraw_printtex_print_csv = PRINT_TEX;
        if ((strcmp ("--help", argv [argi]) == 0) || (strcmp ("-h", argv [argi]) == 0))
            printhelp = PRINT_HELP;
    }
    if (printhelp == PRINT_HELP) {
        printf ("--create-newn-nnn");
        printf ("--read-csvn-rnn");
        printf ("--print-csvn-cnn");
        printf ("--print-texn-tnn");
        printf ("--helpn-hnn");
        return 2;
    }
    if (createnew_readcsv == CREATE_NEW)
        createnew (a, b, y);
    else if (createnew_readcsv == READ_CSV)
        readcsv (a, b, y);
    if (printraw_printtex_print_csv == PRINT_TEX)
        printtex (a, b, y);
    else if (printraw_printtex_print_csv == PRINT_CSV)
        printcsv (a, b, y);
return 0;
}

Image test12-1

// So, das ist jetzt die Eingabefunktion, die ist verbessert

Ich teste die jetzt. Wie geht sie damit um, dass die Eingabe falsch ist. Auch, dass Zeilen fehlen

void readcsv (int a [], int b [], int y [MAX_OUTPUTS][MAX_STATES]) {
    int i;
    int j;
    int i1, i2;
    int x1, x2;
    char s [MAX_STR_INPUT_LEN];

    //scanf ("Zustand,Eingabe,Ausgabe,Folgezustandn");
    scanf ("%sn", s);
    if (strcmp (s, "Zustand,Eingabe,Ausgabe,Folgezustand") != 0) {
            printf ("%sn", ERR_FILE_WRON_FORMAT_MSG);
            exit (ERR_FILE_WRON_FORMAT);
    }

    for (i = 0;  i < MAX_STATES ;  i++) {
        scanf ("%i,%i,%i,%in", \&amp;i1, \&amp;x1, \&amp;y [Z_A][i], \&amp;a [i]);
        scanf ("%i,%i,%i,%in", \&amp;i2, \&amp;x2, \&amp;y [Z_B][i], \&amp;b [i]);
        printf ("%i,%i,%i,%in", i1, x1, y [Z_A][i], a [i]);
        printf ("%i,%i,%i,%in", i2, x2, y [Z_B][i], b [i]);

        if (x1 != Z_A) {
            printf ("%sn", ERR_FILE_WRON_FORMAT_MSG);
            exit (ERR_FILE_WRON_FORMAT);
        }
        if (x2 != Z_B) {
            printf ("%sn", ERR_FILE_WRON_FORMAT_MSG);
            exit (ERR_FILE_WRON_FORMAT);
        }
        if (i1 != (i+1)) {
            printf ("%sn", ERR_FILE_WRON_FORMAT_MSG);
            exit (ERR_FILE_WRON_FORMAT);
        }
        if (i2 != (i+1)) {
            printf ("%sn", ERR_FILE_WRON_FORMAT_MSG);
            exit (ERR_FILE_WRON_FORMAT);
        }
    }

return;
}

OK, die Testmenge von 0 bis 10 hat schon mal nicht beschissen, hier alle zusammen

Zustand,Eingabe,Ausgabe,Folgezustand
1,0,0,3
1,1,0,2
2,0,0,2
2,1,1,4
3,0,1,4
3,1,1,3
4,0,1,1
4,1,0,1
Zustand,Eingabe,Ausgabe,Folgezustand
1,0,0,3
1,1,1,3
2,0,0,1
2,1,1,4
3,0,0,2
3,1,0,2
4,0,1,4
4,1,0,1
Zustand,Eingabe,Ausgabe,Folgezustand
1,0,0,3
1,1,0,2
2,0,0,2
2,1,1,4
3,0,1,4
3,1,1,3
4,0,1,1
4,1,0,1
Zustand,Eingabe,Ausgabe,Folgezustand
1,0,1,3
1,1,1,2
2,0,1,4
2,1,1,4
3,0,0,1
3,1,1,1
4,0,1,2
4,1,0,3
Zustand,Eingabe,Ausgabe,Folgezustand
1,0,1,4
1,1,1,4
2,0,0,3
2,1,1,1
3,0,0,1
3,1,1,3
4,0,1,2
4,1,1,2
Zustand,Eingabe,Ausgabe,Folgezustand
1,0,0,3
1,1,0,4
2,0,1,4
2,1,0,1
3,0,0,2
3,1,1,2
4,0,1,1
4,1,1,3
Zustand,Eingabe,Ausgabe,Folgezustand
1,0,0,3
1,1,0,4
2,0,0,1
2,1,0,2
3,0,0,2
3,1,0,1
4,0,0,4
4,1,0,3
Zustand,Eingabe,Ausgabe,Folgezustand
1,0,1,3
1,1,1,2
2,0,0,4
2,1,0,3
3,0,1,2
3,1,1,1
4,0,1,1
4,1,0,4
Zustand,Eingabe,Ausgabe,Folgezustand
1,0,1,4
1,1,0,4
2,0,1,1
2,1,0,3
3,0,0,2
3,1,0,1
4,0,0,3
4,1,0,2
Zustand,Eingabe,Ausgabe,Folgezustand
1,0,0,3
1,1,1,3
2,0,1,4
2,1,0,4
3,0,0,1
3,1,0,1
4,0,1,2
4,1,1,2
Zustand,Eingabe,Ausgabe,Folgezustand
1,0,0,3
1,1,1,3
2,0,1,4
2,1,1,1
3,0,1,1
3,1,0,4
4,0,0,2
4,1,1,2

Jetzt hat das solche Ergebnisse geliefert, die Time ist ein bisschen langweilig

testvariable: 1707418879
Zustand,Eingabe,Ausgabe,Folgezustand
1,0,0,4
1,1,0,2
2,0,1,1
2,1,1,3
3,0,0,3
3,1,0,4
4,0,0,2
4,1,0,1
testvariable: 1707418882
Zustand,Eingabe,Ausgabe,Folgezustand
1,0,0,2
1,1,0,1
2,0,1,1
2,1,0,3
3,0,1,4
3,1,1,4
4,0,0,3
4,1,1,2
testvariable: 1707418883
Zustand,Eingabe,Ausgabe,Folgezustand
1,0,1,2
1,1,0,2
2,0,0,1
2,1,1,3
3,0,0,4
3,1,1,1
4,0,0,3
4,1,1,4
testvariable: 1707418883
Zustand,Eingabe,Ausgabe,Folgezustand
1,0,1,2
1,1,0,2
2,0,0,1
2,1,1,3
3,0,0,4
3,1,1,1
4,0,0,3
4,1,1,4
testvariable: 1707418884
Zustand,Eingabe,Ausgabe,Folgezustand
1,0,1,3
1,1,0,3
2,0,0,4
2,1,1,4
3,0,1,1
3,1,0,2
4,0,1,2
4,1,1,1
testvariable: 1707418884
Zustand,Eingabe,Ausgabe,Folgezustand
1,0,1,3
1,1,0,3
2,0,0,4
2,1,1,4
3,0,1,1
3,1,0,2
4,0,1,2
4,1,1,1
testvariable: 1707418884
Zustand,Eingabe,Ausgabe,Folgezustand
1,0,1,3
1,1,0,3
2,0,0,4
2,1,1,4
3,0,1,1
3,1,0,2
4,0,1,2
4,1,1,1
testvariable: 1707418885
Zustand,Eingabe,Ausgabe,Folgezustand
1,0,0,2
1,1,1,4
2,0,1,4
2,1,1,1
3,0,0,3
3,1,1,2
4,0,1,1
4,1,0,3
testvariable: 1707418886
Zustand,Eingabe,Ausgabe,Folgezustand
1,0,0,2
1,1,0,1
2,0,1,1
2,1,0,4
3,0,1,4
3,1,1,2
4,0,1,3
4,1,1,3
testvariable: 1707418887
Zustand,Eingabe,Ausgabe,Folgezustand
1,0,0,4
1,1,1,4
2,0,0,1
2,1,0,1
3,0,1,2
3,1,1,2
4,0,0,3
4,1,1,3
testvariable: 1707418887
Zustand,Eingabe,Ausgabe,Folgezustand
1,0,0,4
1,1,1,4
2,0,0,1
2,1,0,1
3,0,1,2
3,1,1,2
4,0,0,3
4,1,1,3
testvariable: 1707418888
Zustand,Eingabe,Ausgabe,Folgezustand
1,0,0,4
1,1,1,1
2,0,1,3
2,1,1,4
3,0,1,2
3,1,0,2
4,0,0,1
4,1,1,3
testvariable: 1707418888
Zustand,Eingabe,Ausgabe,Folgezustand
1,0,0,4
1,1,1,1
2,0,1,3
2,1,1,4
3,0,1,2
3,1,0,2
4,0,0,1
4,1,1,3
testvariable: 1707418889
Zustand,Eingabe,Ausgabe,Folgezustand
1,0,0,3
1,1,1,1
2,0,1,1
2,1,0,3
3,0,0,2
3,1,1,4
4,0,1,4
4,1,1,2
testvariable: 1707418890
Zustand,Eingabe,Ausgabe,Folgezustand
1,0,0,3
1,1,0,4
2,0,0,4
2,1,1,1
3,0,1,1
3,1,0,3
4,0,0,2
4,1,1,2

Also, das sieht gut aus

testvariable: 1707418879
Zustand,Eingabe,Ausgabe,Folgezustand
1,0,0,4
1,1,0,2
2,0,1,1
2,1,1,3
3,0,0,3
3,1,0,4
4,0,0,2
4,1,0,1
testvariable: 1707418882
Zustand,Eingabe,Ausgabe,Folgezustand
1,0,0,2
1,1,0,1
2,0,1,1
2,1,0,3
3,0,1,4
3,1,1,4
4,0,0,3
4,1,1,2
testvariable: 1707418883
Zustand,Eingabe,Ausgabe,Folgezustand
1,0,1,2
1,1,0,2
2,0,0,1
2,1,1,3
3,0,0,4
3,1,1,1
4,0,0,3
4,1,1,4
testvariable: 1707418883
Zustand,Eingabe,Ausgabe,Folgezustand
1,0,1,2
1,1,0,2
2,0,0,1
2,1,1,3
3,0,0,4
3,1,1,1
4,0,0,3
4,1,1,4
testvariable: 1707418884
Zustand,Eingabe,Ausgabe,Folgezustand
1,0,1,3
1,1,0,3
2,0,0,4
2,1,1,4
3,0,1,1
3,1,0,2
4,0,1,2
4,1,1,1
testvariable: 1707418884
Zustand,Eingabe,Ausgabe,Folgezustand
1,0,1,3
1,1,0,3
2,0,0,4
2,1,1,4
3,0,1,1
3,1,0,2
4,0,1,2
4,1,1,1
testvariable: 1707418884
Zustand,Eingabe,Ausgabe,Folgezustand
1,0,1,3
1,1,0,3
2,0,0,4
2,1,1,4
3,0,1,1
3,1,0,2
4,0,1,2
4,1,1,1
testvariable: 1707418885
Zustand,Eingabe,Ausgabe,Folgezustand
1,0,0,2
1,1,1,4
2,0,1,4
2,1,1,1
3,0,0,3
3,1,1,2
4,0,1,1
4,1,0,3
testvariable: 1707418886
Zustand,Eingabe,Ausgabe,Folgezustand
1,0,0,2
1,1,0,1
2,0,1,1
2,1,0,4
3,0,1,4
3,1,1,2
4,0,1,3
4,1,1,3
testvariable: 1707418887
Zustand,Eingabe,Ausgabe,Folgezustand
1,0,0,4
1,1,1,4
2,0,0,1
2,1,0,1
3,0,1,2
3,1,1,2
4,0,0,3
4,1,1,3
testvariable: 1707418887
Zustand,Eingabe,Ausgabe,Folgezustand
1,0,0,4
1,1,1,4
2,0,0,1
2,1,0,1
3,0,1,2
3,1,1,2
4,0,0,3
4,1,1,3
testvariable: 1707418888
Zustand,Eingabe,Ausgabe,Folgezustand
1,0,0,4
1,1,1,1
2,0,1,3
2,1,1,4
3,0,1,2
3,1,0,2
4,0,0,1
4,1,1,3
testvariable: 1707418888
Zustand,Eingabe,Ausgabe,Folgezustand
1,0,0,4
1,1,1,1
2,0,1,3
2,1,1,4
3,0,1,2
3,1,0,2
4,0,0,1
4,1,1,3
testvariable: 1707418889
Zustand,Eingabe,Ausgabe,Folgezustand
1,0,0,3
1,1,1,1
2,0,1,1
2,1,0,3
3,0,0,2
3,1,1,4
4,0,1,4
4,1,1,2
testvariable: 1707418890
Zustand,Eingabe,Ausgabe,Folgezustand
1,0,0,3
1,1,0,4
2,0,0,4
2,1,1,1
3,0,1,1
3,1,0,3
4,0,0,2
4,1,1,2
testvariable: 100
Zustand,Eingabe,Ausgabe,Folgezustand
1,0,1,3
1,1,0,4
2,0,0,4
2,1,1,1
3,0,0,1
3,1,0,2
4,0,0,2
4,1,1,3
testvariable: 1000
Zustand,Eingabe,Ausgabe,Folgezustand
1,0,1,1
1,1,1,3
2,0,0,3
2,1,0,1
3,0,1,4
3,1,0,2
4,0,1,2
4,1,1,4
testvariable: 10000
Zustand,Eingabe,Ausgabe,Folgezustand
1,0,0,3
1,1,0,2
2,0,0,1
2,1,0,4
3,0,0,4
3,1,0,3
4,0,0,2
4,1,0,1
testvariable: 100000
Zustand,Eingabe,Ausgabe,Folgezustand
1,0,1,4
1,1,1,2
2,0,0,3
2,1,0,4
3,0,0,2
3,1,1,3
4,0,1,1
4,1,0,1
testvariable: 1024
Zustand,Eingabe,Ausgabe,Folgezustand
1,0,0,4
1,1,1,3
2,0,1,1
2,1,0,4
3,0,1,2
3,1,0,2
4,0,1,3
4,1,1,1
testvariable: 2048
Zustand,Eingabe,Ausgabe,Folgezustand
1,0,0,3
1,1,0,2
2,0,1,4
2,1,1,3
3,0,1,2
3,1,0,1
4,0,1,1
4,1,0,4
testvariable: 4096
Zustand,Eingabe,Ausgabe,Folgezustand
1,0,1,4
1,1,1,4
2,0,0,3
2,1,0,2
3,0,0,1
3,1,1,1
4,0,0,2
4,1,1,3
testvariable: 8192
Zustand,Eingabe,Ausgabe,Folgezustand
1,0,0,4
1,1,1,3
2,0,1,2
2,1,0,1
3,0,1,1
3,1,1,2
4,0,1,3
4,1,0,4
testvariable: 13
Zustand,Eingabe,Ausgabe,Folgezustand
1,0,0,4
1,1,1,4
2,0,0,3
2,1,1,1
3,0,1,2
3,1,0,2
4,0,0,1
4,1,1,3
testvariable: 19
Zustand,Eingabe,Ausgabe,Folgezustand
1,0,1,4
1,1,1,1
2,0,1,1
2,1,0,2
3,0,1,3
3,1,0,4
4,0,1,2
4,1,0,3

Im nächsten Schritt, übernehme ich das - im Alten Programm, weil das war das Testprogramm, ich habe bei scanf was geändert. Es scant jetzt die Tabellenüberschriften ein. Damit das Format garantiert ist - das ist so etwas, wie die Magic Number.

OK, dann werde ich die Funktion durchlesen, was ich getestet habe, lese ich gleich.

Ich sehe jetzt nicht, was da falsch ist

// So, das ist jetzt die Eingabefunktion, die ist verbessert

Ich teste die jetzt. Wie geht sie damit um, dass die Eingabe falsch ist. Auch, dass Zeilen fehlen

void readcsv (int a [], int b [], int y [MAX_OUTPUTS][MAX_STATES]) {
    int i;
    int j;
    int i1, i2;
    int x1, x2;
    char s [MAX_STR_INPUT_LEN];

    //scanf ("Zustand,Eingabe,Ausgabe,Folgezustandn");
    scanf ("%sn", s);
    if (strcmp (s, "Zustand,Eingabe,Ausgabe,Folgezustand") != 0) {
            printf ("%sn", ERR_FILE_WRON_FORMAT_MSG);
            exit (ERR_FILE_WRON_FORMAT);
    }

    for (i = 0;  i < MAX_STATES ;  i++) {
        scanf ("%i,%i,%i,%in", \&amp;i1, \&amp;x1, \&amp;y [Z_A][i], \&amp;a [i]);
        scanf ("%i,%i,%i,%in", \&amp;i2, \&amp;x2, \&amp;y [Z_B][i], \&amp;b [i]);
        printf ("%i,%i,%i,%in", i1, x1, y [Z_A][i], a [i]);
        printf ("%i,%i,%i,%in", i2, x2, y [Z_B][i], b [i]);

        if (x1 != Z_A) {
            printf ("%sn", ERR_FILE_WRON_FORMAT_MSG);
            exit (ERR_FILE_WRON_FORMAT);
        }
        if (x2 != Z_B) {
            printf ("%sn", ERR_FILE_WRON_FORMAT_MSG);
            exit (ERR_FILE_WRON_FORMAT);
        }
        if (i1 != (i+1)) {
            printf ("%sn", ERR_FILE_WRON_FORMAT_MSG);
            exit (ERR_FILE_WRON_FORMAT);
        }
        if (i2 != (i+1)) {
            printf ("%sn", ERR_FILE_WRON_FORMAT_MSG);
            exit (ERR_FILE_WRON_FORMAT);
        }
    }

return;
}

david@laptop-peaq:~\$ cat testmenge10.csv | ./a.out -s
1,0,0,3
1,1,1,3
2,0,0,1
2,1,1,4
3,0,0,2
3,1,0,2
4,0,1,4
4,1,0,1
Zustand,Eingabe,Ausgabe,Folgezustand
1,0,0,3
1,1,1,3
2,0,0,1
2,1,1,4
3,0,0,2
3,1,0,2
4,0,1,4
4,1,0,1
david@laptop-peaq:~\$

In sofern kann ja nichts falsch sein. Aber, nein, das passt so

Dann mache ich das so - als Testmenge lese ich jetzt testdatei erstellt aus. Gebe sie so wieder aus. In eine neue Datei Dazu mache ich ein Bash Skript Und im Bashskript überprüfe ich, ob die alte datei der neuen Datei 1:1 entspricht.

// So ich habe das jetzt getestet, hier erst Mal das Programm

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

#define ERR_FILE_WRON_FORMAT            3
#define ERR_FILE_WRON_FORMAT_MSG        "IO-Error: File Wrong Format"
#define MAX_STR_INPUT_LEN               128

#define MAX_SPECIAL_STATES      3
#define MAX_STATES              4
#define MIN_STATE               1
#define SPECIAL_STATE_1         1
#define SPECIAL_STATE_2         2
#define SPECIAL_STATE_3         3
#define MAX_INPUTS              2
#define MAX_OUTPUTS             2
#define TRUE                    1
#define FALSE                   0
#define Z_A                     0
#define Z_B                     1

void readcsv (int a [], int b [], int y [MAX_OUTPUTS][MAX_STATES]) {
    int i;
    int j;
    int i1, i2;
    int x1, x2;
    char s [MAX_STR_INPUT_LEN];

    //scanf ("Zustand,Eingabe,Ausgabe,Folgezustandn");
    scanf ("%sn", s);
    if (strcmp (s, "Zustand,Eingabe,Ausgabe,Folgezustand") != 0) {
            printf ("%sn", ERR_FILE_WRON_FORMAT_MSG);
            exit (ERR_FILE_WRON_FORMAT);
    }

    for (i = 0;  i < MAX_STATES ;  i++) {
        scanf ("%i,%i,%i,%in", \&amp;i1, \&amp;x1, \&amp;y [Z_A][i], \&amp;a [i]);
        scanf ("%i,%i,%i,%in", \&amp;i2, \&amp;x2, \&amp;y [Z_B][i], \&amp;b [i]);

        if (x1 != Z_A) {
            printf ("%sn", ERR_FILE_WRON_FORMAT_MSG);
            exit (ERR_FILE_WRON_FORMAT);
        }
        if (x2 != Z_B) {
            printf ("%sn", ERR_FILE_WRON_FORMAT_MSG);
            exit (ERR_FILE_WRON_FORMAT);
        }
        if (i1 != (i+1)) {
            printf ("%sn", ERR_FILE_WRON_FORMAT_MSG);
            exit (ERR_FILE_WRON_FORMAT);
        }
        if (i2 != (i+1)) {
            printf ("%sn", ERR_FILE_WRON_FORMAT_MSG);
            exit (ERR_FILE_WRON_FORMAT);
        }
    }

return;
}

void printcsv (int a [], int b [], int y [MAX_OUTPUTS][MAX_STATES]) {
    int i;
    printf ("Zustand,Eingabe,Ausgabe,Folgezustandn");

    for (i = 0;  i < (MAX_STATES);  i++) {
        printf ("%i,%i,%i,%in", i+MIN_STATE, Z_A, y [Z_A][i], a [i]);
        printf ("%i,%i,%i,%in", i+MIN_STATE, Z_B, y [Z_B][i], b [i]);
    }

return;
}

void createnew (int a [], int b [], int y [MAX_OUTPUTS][MAX_STATES]) {
#define RAND_1      32
#define RAND_2      16
#define RAND_3      16
#define RAND_4      8

#define N_SORTS     8
    time_t t;
    int i, j;
    int flag;
    int s;

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

    for (i = 0;  i < MAX_STATES;  i++) {
        a [i] = i + MIN_STATE;
        b [i] = i + MIN_STATE;
    }
    flag = 0;
    for (s = 0;  s < N_SORTS;  s++)
        while (!flag) {
            for (i = 0;  i < MAX_STATES;  i++) {
                for (j = i + 1;  j < MAX_STATES;  j++) {
                    if ((rand () % RAND_1) > RAND_2) {
                        t = a [j];
                        a [j] = a [i];
                        a [i] = t;
                    }
                }
            }
            for (i = 0;  i < MAX_STATES;  i++) {
                for (j = i + 1;  j < MAX_STATES;  j++) {
                    if ((rand () % RAND_3) < RAND_4) {
                        t = b [j];
                        b [j] = b [i];
                        b [i] = t;
                    }
                }
            }
            flag = TRUE;
            for (i = 0;  i < MAX_STATES;  i++)
                if ((a [i] == b [i]) \&amp;\&amp; (b [i] == (i+MIN_STATE))) {
                    flag = FALSE;
                }

        }
    for (i = 0;  i < MAX_STATES;  i++) {
        y [Z_A][i] = rand () % MAX_OUTPUTS;
        y [Z_B][i] = rand () % MAX_OUTPUTS;
    }

return;
}

void printtex (int a [], int b [], int y [MAX_OUTPUTS][MAX_STATES]) {
    int i, j;
    int codez = 8;
    printf("\documentclass{article}n");
    printf("\usepackage[utf8]{inputenc}n");
    printf("\usepackage{pgf, tikz}n");
    printf("\usetikzlibrary{arrows , automata , positioning}n");
    printf("\begin{document}nn");

    printf("\begin{center}n");
    printf("\begin{tikzpicture}[>=stealth',shorten >=1pt,auto,node distance=2.5cm]n");
    printf("%Knotenn");

    printf("\node (1) [state, thick] {1};n");
    printf("\node (2) [state, thick, right of= 1] {2};n");
    printf("\node (3) [state, thick, above of= 2, right of= 2] {3};n");
    printf("\node (4) [state, thick, above of= 3, right of= 1] {4};nn");

    printf("%Verbindungenn");
    printf("\path[thick,->]n");

    char *leftright [] = {"left", "right"};
    char *abovebelow [] = {"above", "below"};

    for (i = 0;  i < MAX_STATES;  i++) {
            if ((a [i] - MIN_STATE) == i)
                printf ("(%i) edge [loop] node {%i/%i} (%i)n", i + MIN_STATE, Z_A, y [Z_A][i], a [i]);
            else
                printf ("(%i) edge [bend angle=%i, bend %s,%s] node {%i/%i} (%i)n", i + MIN_STATE, (i+1)*10+(a[i]-MIN_STATE)*5, leftright [(i>(a [i]-MIN_STATE))\&amp;\&amp;((a [i]-MIN_STATE) != 3)], abovebelow    [((i+1)<=a[i])\&amp;\&amp;(a[i] != 4)], Z_A, y [Z_A][i], a [i]);
            if ((b [i] - MIN_STATE) == i)
                printf ("(%i) edge [loop] node {%i/%i} (%i)n", i + MIN_STATE, Z_B, y [Z_B][i], b [i]);
            else
                printf ("(%i) edge [bend angle=%i, bend %s,%s] node {%i/%i} (%i)n", i + MIN_STATE, (i+1)*25+(b[i]-MIN_STATE)*8, leftright [(i<=(b [i]-MIN_STATE)) \&amp;\&amp;((b [i]-MIN_STATE) != 3)], abovebelow [((i+MIN_STATE)>b [i])\&amp;\&amp;(b [i] != 4)], Z_B, y [Z_B][i], b [i]);
    }
    printf(";n");
    printf("\end{tikzpicture}n");
    printf("\end{center}n");

    printf ("\begin{center}n");
    printf ("\begin{tabular}{|l|l|l|l||l|l|l|l|}n");
    n");
    printf ("Zustand \&amp; Eingabe \&amp; Ausgabe \&amp; Folgezustand \&amp; \multicolumn{4}{|l|}{Codefolgezustand}n");
    n");
    printf BITTE IM PDF NACHGUCKEN
    n");
    for (i = 0;  i < MAX_STATES;  i++) {
        printf BITTE IM PDF NACHGUCKEN
        printf BITTE IM PDF NACHGUCKEN

    }
    n");
    printf ("\end{tabular}n");
    printf ("\end{center}n");

    printf ("\begin{center}n");
    printf ("\begin{verbatim}n");
    for (i = MIN_STATE;  i < (MAX_STATES + MIN_STATE);  i++) {
        printf ("z%i+ := ", i);
        for (j = 0;  j < MAX_STATES;  j++) {
            if ( a [j] == i )
                printf ("z%i and x or ", j+MIN_STATE, y [j]);
            if ( b [j] == i )
                printf ("z%i and not x or ", j+MIN_STATE, y [j]);
        }
        printf (" true;n");
    }
    printf ("end{verbatim}n");
    printf ("\end{center}n");

    printf("\end{document}n");

}

int main (int argc, char *argv []) {
    #define CREATE_NEW      0
    #define READ_CSV        1
    #define PRINT_TEX       0
    #define PRINT_CSV       1
    #define PRINT_NO_HELP   0
    #define PRINT_HELP      1

    int b [MAX_STATES];
    int a [MAX_STATES];
    int y [MAX_OUTPUTS][MAX_STATES];
    int argi;
    int createnew_readcsv = CREATE_NEW;
    int printraw_printtex_print_csv = PRINT_CSV;
    int printhelp = PRINT_NO_HELP;

    for (argi = 1;  argi < argc;  argi++) {
        if ((strcmp ("--create-new", argv [argi]) == 0) || (strcmp ("-n", argv [argi]) == 0))
            createnew_readcsv = CREATE_NEW;
        if ((strcmp ("--read-csv", argv [argi]) == 0) || (strcmp ("-s", argv [argi]) == 0))
            createnew_readcsv = READ_CSV;
        if ((strcmp ("--print-csv", argv [argi]) == 0) || (strcmp ("-c", argv [argi]) == 0))
            printraw_printtex_print_csv = PRINT_CSV;
        if ((strcmp ("--print-tex", argv [argi]) == 0) || (strcmp ("-t", argv [argi]) == 0))
                printraw_printtex_print_csv = PRINT_TEX;
        if ((strcmp ("--help", argv [argi]) == 0) || (strcmp ("-h", argv [argi]) == 0))
            printhelp = PRINT_HELP;
    }
    if (printhelp == PRINT_HELP) {
        printf ("--create-newn-nnn");
        printf ("--read-csvn-rnn");
        printf ("--print-csvn-cnn");
        printf ("--print-texn-tnn");
        printf ("--helpn-hnn");
        return 2;
    }
    if (createnew_readcsv == CREATE_NEW)
        createnew (a, b, y);
    else if (createnew_readcsv == READ_CSV)
        readcsv (a, b, y);
    if (printraw_printtex_print_csv == PRINT_TEX)
        printtex (a, b, y);
    else if (printraw_printtex_print_csv == PRINT_CSV)
        printcsv (a, b, y);
return 0;
}

# So, mit dem Programm habe ich das getestet

#!/bin/bash

l=\$(ls testmenge*.csv)

for s in \$l
do
 cat \$s | ./a.out -s > "\$s""2.csv"
 diff \$s "\$s""2.csv"
done

Also, nach der Testmenge ist das Programm mit den Eingabedaten richtig. Und der Ausgabe. Den TeX Output muss man nicht testen. Der ist richtig, sonst wäre es schon falsch gewesen. Jetzt teste ich, die Optionen. Ich teste jede Option einzelne. Und was das Programm erlaubt, sie hintereinander ein zu geben, widersprechen sie sich - dann zählt die letzte.

Also, die Ausgabe, ohne Parameter, tut

david@laptop-peaq:~\$ ./a.out
Zustand,Eingabe,Ausgabe,Folgezustand
1,0,1,4
1,1,0,4
2,0,0,1
2,1,0,3
3,0,1,3
3,1,0,2
4,0,0,2
4,1,0,1
david@laptop-peaq:~\$ ./a.out
Zustand,Eingabe,Ausgabe,Folgezustand
1,0,0,1
1,1,0,4
2,0,1,4
2,1,1,3
3,0,0,2
3,1,1,1
4,0,0,3
4,1,1,2
david@laptop-peaq:~\$ ./a.out
Zustand,Eingabe,Ausgabe,Folgezustand
1,0,1,3
1,1,1,4
2,0,0,2
2,1,0,1
3,0,0,4
3,1,0,3
4,0,1,1
4,1,0,2
david@laptop-peaq:~\$ ./a.out
Zustand,Eingabe,Ausgabe,Folgezustand
1,0,0,3
1,1,1,2
2,0,0,4
2,1,0,1
3,0,0,2
3,1,0,3
4,0,1,1
4,1,1,4
david@laptop-peaq:~\$

// Die Ausgabe mit widerspr"uchlichen Parametern tut

david@laptop-peaq:~\$ ./a.out
Zustand,Eingabe,Ausgabe,Folgezustand
1,0,1,4
1,1,0,4
2,0,0,1
2,1,0,3
3,0,1,3
3,1,0,2
4,0,0,2
4,1,0,1
david@laptop-peaq:~\$ ./a.out
Zustand,Eingabe,Ausgabe,Folgezustand
1,0,0,1
1,1,0,4
2,0,1,4
2,1,1,3
3,0,0,2
3,1,1,1
4,0,0,3
4,1,1,2
david@laptop-peaq:~\$ ./a.out
Zustand,Eingabe,Ausgabe,Folgezustand
1,0,1,3
1,1,1,4
2,0,0,2
2,1,0,1
3,0,0,4
3,1,0,3
4,0,1,1
4,1,0,2
david@laptop-peaq:~\$ ./a.out
Zustand,Eingabe,Ausgabe,Folgezustand
1,0,0,3
1,1,1,2
2,0,0,4
2,1,0,1
3,0,0,2
3,1,0,3
4,0,1,1
4,1,1,4
david@laptop-peaq:~\$ ./a.out -n
Zustand,Eingabe,Ausgabe,Folgezustand
1,0,0,2
1,1,0,4
2,0,1,1
2,1,0,1
3,0,1,3
3,1,1,2
4,0,1,4
4,1,0,3
david@laptop-peaq:~\$ ./a.out -n
Zustand,Eingabe,Ausgabe,Folgezustand
1,0,0,4
1,1,1,4
2,0,1,3
2,1,0,1
3,0,1,1
3,1,0,3
4,0,1,2
4,1,1,2
david@laptop-peaq:~\$ ./a.out -n
Zustand,Eingabe,Ausgabe,Folgezustand
1,0,0,1
1,1,0,4
2,0,1,4
2,1,0,3
3,0,0,3
3,1,1,1
4,0,1,2
4,1,0,2
david@laptop-peaq:~\$ ./a.out -n -s -n
Zustand,Eingabe,Ausgabe,Folgezustand
1,0,1,2
1,1,0,4
2,0,1,4
2,1,0,2
3,0,0,1
3,1,1,3
4,0,1,3
4,1,0,1
david@laptop-peaq:~\$ ./a.out -n -s -n
Zustand,Eingabe,Ausgabe,Folgezustand
1,0,1,3
1,1,1,1
2,0,0,4
2,1,0,3
3,0,1,1
3,1,1,4
4,0,1,2
4,1,0,2
david@laptop-peaq:~\$ ./a.out -n -s -n -s
\^C
david@laptop-peaq:~\$ ./a.out -n -s -n -s -n
Zustand,Eingabe,Ausgabe,Folgezustand
1,0,1,2
1,1,1,3
2,0,0,4
2,1,1,2
3,0,1,1
3,1,0,4
4,0,1,3
4,1,1,1
david@laptop-peaq:~\$

Mit -t und -c auch - ich denke, ich mache noch den Elchtest - einlesen und TeX Output, dann fertig

david@laptop-peaq:~\$ ./a.out
Zustand,Eingabe,Ausgabe,Folgezustand
1,0,1,4
1,1,0,4
2,0,0,1
2,1,0,3
3,0,1,3
3,1,0,2
4,0,0,2
4,1,0,1
david@laptop-peaq:~\$ ./a.out
Zustand,Eingabe,Ausgabe,Folgezustand
1,0,0,1
1,1,0,4
2,0,1,4
2,1,1,3
3,0,0,2
3,1,1,1
4,0,0,3
4,1,1,2
david@laptop-peaq:~\$ ./a.out
Zustand,Eingabe,Ausgabe,Folgezustand
1,0,1,3
1,1,1,4
2,0,0,2
2,1,0,1
3,0,0,4
3,1,0,3
4,0,1,1
4,1,0,2
david@laptop-peaq:~\$ ./a.out
Zustand,Eingabe,Ausgabe,Folgezustand
1,0,0,3
1,1,1,2
2,0,0,4
2,1,0,1
3,0,0,2
3,1,0,3
4,0,1,1
4,1,1,4
david@laptop-peaq:~\$ ./a.out -n
Zustand,Eingabe,Ausgabe,Folgezustand
1,0,0,2
1,1,0,4
2,0,1,1
2,1,0,1
3,0,1,3
3,1,1,2
4,0,1,4
4,1,0,3
david@laptop-peaq:~\$ ./a.out -n
Zustand,Eingabe,Ausgabe,Folgezustand
1,0,0,4
1,1,1,4
2,0,1,3
2,1,0,1
3,0,1,1
3,1,0,3
4,0,1,2
4,1,1,2
david@laptop-peaq:~\$ ./a.out -n
Zustand,Eingabe,Ausgabe,Folgezustand
1,0,0,1
1,1,0,4
2,0,1,4
2,1,0,3
3,0,0,3
3,1,1,1
4,0,1,2
4,1,0,2
david@laptop-peaq:~\$ ./a.out -n -s -n
Zustand,Eingabe,Ausgabe,Folgezustand
1,0,1,2
1,1,0,4
2,0,1,4
2,1,0,2
3,0,0,1
3,1,1,3
4,0,1,3
4,1,0,1
david@laptop-peaq:~\$ ./a.out -n -s -n
Zustand,Eingabe,Ausgabe,Folgezustand
1,0,1,3
1,1,1,1
2,0,0,4
2,1,0,3
3,0,1,1
3,1,1,4
4,0,1,2
4,1,0,2
david@laptop-peaq:~\$ ./a.out -n -s -n -s
\^C
david@laptop-peaq:~\$ ./a.out -n -s -n -s -n
Zustand,Eingabe,Ausgabe,Folgezustand
1,0,1,2
1,1,1,3
2,0,0,4
2,1,1,2
3,0,1,1
3,1,0,4
4,0,1,3
4,1,1,1
david@laptop-peaq:~\$ ./a.out -n -s -n -s -n -t
documentclass{article}
usepackage[utf8]{inputenc}
usepackage{pgf, tikz}
usetikzlibrary{arrows , automata , positioning}
begin{document}

begin{center}
begin{tikzpicture}[>=stealth',shorten >=1pt,auto,node distance=2.5cm]
%Knoten
node (1) [state, thick] {1};
node (2) [state, thick, right of= 1] {2};
node (3) [state, thick, above of= 2, right of= 2] {3};
node (4) [state, thick, above of= 3, right of= 1] {4};

%Verbindungen
path[thick,->]
(1) edge [loop] node {0/1} (1)
(1) edge [bend angle=33, bend right,above] node {1/0} (2)
(2) edge [bend angle=35, bend left,above] node {0/0} (4)
(2) edge [bend angle=66, bend right,above] node {1/1} (3)
(3) edge [loop] node {0/1} (3)
(3) edge [bend angle=99, bend left,above] node {1/0} (4)
(4) edge [bend angle=45, bend right,above] node {0/1} (2)
(4) edge [bend angle=100, bend left,below] node {1/0} (1)
;
end{tikzpicture}
end{center}
begin{center}
begin{tabular}{|l|l|l|l||l|l|l|l|}
hline
Zustand \&amp; Eingabe \&amp; Ausgabe \&amp; Folgezustand \&amp; multicolumn{4}{|l|}{Codefolgezustand}\
hline
\&amp; \&amp; \&amp; \&amp; verb"z3+" \&amp;  verb"z2+" \&amp;  verb"z1+" \&amp;  verb"z0+"\
hline
verb"z1" \&amp; verb"0" \&amp;  verb"1" \&amp; verb"z1" \&amp; verb"0"  \&amp; verb"0"  \&amp; verb"0"  \&amp; verb"1"\
verb"z1" \&amp; verb"1" \&amp;  verb"0" \&amp; verb"z2" \&amp; verb"0"  \&amp; verb"0"  \&amp; verb"1"  \&amp; verb"0"\
verb"z2" \&amp; verb"0" \&amp;  verb"0" \&amp; verb"z4" \&amp; verb"1"  \&amp; verb"0"  \&amp; verb"0"  \&amp; verb"0"\
verb"z2" \&amp; verb"1" \&amp;  verb"1" \&amp; verb"z3" \&amp; verb"0"  \&amp; verb"1"  \&amp; verb"0"  \&amp; verb"0"\
verb"z3" \&amp; verb"0" \&amp;  verb"1" \&amp; verb"z3" \&amp; verb"0"  \&amp; verb"1"  \&amp; verb"0"  \&amp; verb"0"\
verb"z3" \&amp; verb"1" \&amp;  verb"0" \&amp; verb"z4" \&amp; verb"1"  \&amp; verb"0"  \&amp; verb"0"  \&amp; verb"0"\
verb"z4" \&amp; verb"0" \&amp;  verb"1" \&amp; verb"z2" \&amp; verb"0"  \&amp; verb"0"  \&amp; verb"1"  \&amp; verb"0"\
verb"z4" \&amp; verb"1" \&amp;  verb"0" \&amp; verb"z1" \&amp; verb"0"  \&amp; verb"0"  \&amp; verb"0"  \&amp; verb"1"\
hline
end{tabular}
end{center}
begin{center}
begin{verbatim}
z1+ := z1 and x or z4 and not x or  true;
z2+ := z1 and not x or z4 and x or  true;
z3+ := z2 and not x or z3 and x or  true;
z4+ := z2 and x or z3 and not x or  true;
end{verbatim}
end{center}
end{document}
david@laptop-peaq:~\$ ./a.out -n -s -n -s -n -t -c
Zustand,Eingabe,Ausgabe,Folgezustand
1,0,0,2
1,1,1,4
2,0,1,4
2,1,1,3
3,0,0,3
3,1,0,1
4,0,1,1
4,1,0,2
david@laptop-peaq:~\$ ./a.out -n -s -n -s -n -t -c -t
documentclass{article}
usepackage[utf8]{inputenc}
usepackage{pgf, tikz}
usetikzlibrary{arrows , automata , positioning}
begin{document}

begin{center}
begin{tikzpicture}[>=stealth',shorten >=1pt,auto,node distance=2.5cm]
%Knoten
node (1) [state, thick] {1};
node (2) [state, thick, right of= 1] {2};
node (3) [state, thick, above of= 2, right of= 2] {3};
node (4) [state, thick, above of= 3, right of= 1] {4};

%Verbindungen
path[thick,->]
(1) edge [bend angle=15, bend left,below] node {0/0} (2)
(1) edge [bend angle=49, bend left,above] node {1/0} (4)
(2) edge [bend angle=20, bend right,above] node {0/0} (1)
(2) edge [bend angle=66, bend right,above] node {1/0} (3)
(3) edge [bend angle=45, bend left,above] node {0/1} (4)
(3) edge [bend angle=83, bend left,below] node {1/1} (2)
(4) edge [bend angle=50, bend right,above] node {0/1} (3)
(4) edge [bend angle=100, bend left,below] node {1/1} (1)
;
end{tikzpicture}
end{center}
begin{center}
begin{tabular}{|l|l|l|l||l|l|l|l|}
hline
Zustand \&amp; Eingabe \&amp; Ausgabe \&amp; Folgezustand \&amp; multicolumn{4}{|l|}{Codefolgezustand}\
hline
\&amp; \&amp; \&amp; \&amp; verb"z3+" \&amp;  verb"z2+" \&amp;  verb"z1+" \&amp;  verb"z0+"\
hline
verb"z1" \&amp; verb"0" \&amp;  verb"0" \&amp; verb"z2" \&amp; verb"0"  \&amp; verb"0"  \&amp; verb"1"  \&amp; verb"0"\
verb"z1" \&amp; verb"1" \&amp;  verb"0" \&amp; verb"z4" \&amp; verb"1"  \&amp; verb"0"  \&amp; verb"0"  \&amp; verb"0"\
verb"z2" \&amp; verb"0" \&amp;  verb"0" \&amp; verb"z1" \&amp; verb"0"  \&amp; verb"0"  \&amp; verb"0"  \&amp; verb"1"\
verb"z2" \&amp; verb"1" \&amp;  verb"0" \&amp; verb"z3" \&amp; verb"0"  \&amp; verb"1"  \&amp; verb"0"  \&amp; verb"0"\
verb"z3" \&amp; verb"0" \&amp;  verb"1" \&amp; verb"z4" \&amp; verb"1"  \&amp; verb"0"  \&amp; verb"0"  \&amp; verb"0"\
verb"z3" \&amp; verb"1" \&amp;  verb"1" \&amp; verb"z2" \&amp; verb"0"  \&amp; verb"0"  \&amp; verb"1"  \&amp; verb"0"\
verb"z4" \&amp; verb"0" \&amp;  verb"1" \&amp; verb"z3" \&amp; verb"0"  \&amp; verb"1"  \&amp; verb"0"  \&amp; verb"0"\
verb"z4" \&amp; verb"1" \&amp;  verb"1" \&amp; verb"z1" \&amp; verb"0"  \&amp; verb"0"  \&amp; verb"0"  \&amp; verb"1"\
hline
end{tabular}
end{center}
begin{center}
begin{verbatim}
z1+ := z2 and x or z4 and not x or  true;
z2+ := z1 and x or z3 and not x or  true;
z3+ := z2 and not x or z4 and x or  true;
z4+ := z1 and not x or z3 and x or  true;
end{verbatim}
end{center}
end{document}
david@laptop-peaq:~\$