Re: Aufgaben und Übungen,

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

#define EMPTY_Z -1
#define UNINIT_Z -2

int main (void) {
    time_t t;
    int i, j;
    int z [4][2];
    int flag;

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


    for (i = 0;  i < 4;  i++) {
        z [i][0] = i;
        z [i][1] = i;
    }
    flag = 0;
    while (!flag) {
        for (i = 0;  i < 4;  i++) {
            for (j = i + 1;  j < 4;  j++) {
                if ((rand () % 32) > 16) {
                    t = z [j][0];
                    z [j][0] = z[i][0];
                    z [i][0] = t;
                }
            }
        }
        for (i = 0;  i < 4;  i++) {
            for (j = i + 1;  j < 4;  j++) {
                if ((rand () % 16) < 8) {
                    t = z [j][1];
                    z [j][1] = z[i][1];
                    z [i][1] = t;
                }
            }
        }
        flag = 1;
        for (i = 0;  i < 4;  i++)
            if ((z[i][0] == z[i][1]) \&amp;\&amp; (z[i][1] == i)) {
                flag = 0;
            }

    }

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 (0) [state, thick] {0};n");
printf("\node (1) [state, thick, right of= 0] {1};n");
printf("\node (2) [state, thick, above of= 1, right of=1] {2};n");
printf("\node (3) [state, thick, above of= 2, left of=0] {3};nn");

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


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

for (i = 0;  i < 4;  i++) {
        j = 0;
        fprintf(stderr, "%in", z [i][0]);
        if (z [i][j] == i)
            printf ("(%i) edge [loop] node {%i/%i} (%i)n", i, j, rand () % 4, z[i][j]);
        else
            printf ("(%i) edge [bend angle=%i, bend %s,%s] node {%i/%i} (%i)n", i, (i+1)*10+z[j][j]*5, leftright [(i>z[i][j])\&amp;\&amp;(z[i][j] != 3)], abovebelow [(i<=z[i][j])\&amp;\&amp;(z[i][j] != 3)], j, rand () % 4, z[i][j]);
        j = 1;
        if (z [i][j] == i)
            printf ("(%i) edge [loop] node {%i/%i} (%i)n", i, j, rand () % 4, z[i][j]);
        else
            printf ("(%i) edge [bend angle=%i, bend %s,%s] node {%i/%i} (%i)n", i, (i+1)*25+z[j][j]*8, leftright [(i<=z[i][j]) \&amp;\&amp;(z[i][j] != 3)], abovebelow [(i>z[i][j])\&amp;\&amp;(z[i][j] != 3)], j, rand () % 4, z[i][j]);
}
printf(";n");
printf("\end{tikzpicture}n");
printf("\end{center}n");
printf("\end{document}n");


return 0;
}

Image test10.pdf

Image test11.pdf

Image test12.pdf

Image test13.pdf

Image test14.pdf

Image test15.pdf

Image test16.pdf

Image test17.pdf

Image test18.pdf

Image test19.pdf

Image test20.pdf

Image test21.pdf

Image test22.pdf

Image test23.pdf

Image test24.pdf

Image test25.pdf

Image test26.pdf

Image test27.pdf

Image test28.pdf

Image test29.pdf

Image test30.pdf

Image test31.pdf

Image test32.pdf

Image test33.pdf

Image test34.pdf

Image test35.pdf

Image test36.pdf

Image test37.pdf

Image test38.pdf

Image test39.pdf

Image test3.pdf

Image test40.pdf

Image test41.pdf

Image test42.pdf

Image test43.pdf

Image test44.pdf

Image test46.pdf

Image test47.pdf

Image test48.pdf

Image test49.pdf

Image test4.pdf

Image test50.pdf

Image test51.pdf

Image test52.pdf

Image test53.pdf

Image test54.pdf

Image test55.pdf

Image test56.pdf

Image test57.pdf

Image test58.pdf

Image test59.pdf

Image test5.pdf

Image test6.pdf

Image test7.pdf

Image test8.pdf

Image test.pdf