#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][4]; int v; int k, l; int n; srand ((unsigned)time (\&t)); for (i = 0; i < 4; i++) { for (j = 0; j < 4; j++) z [i][j] = j; } for (n = rand () % 100; n >= 0; n--) { for (i = 0; i < 4; i++) { if ((rand () % 2) == 0) { for (k = 0; k < 4; k++) { for (l = k + 1; l < 4; l++) { if (z[i][l] > z[i][k]) { t = z [i][l]; z [i][l] = z[i][k]; z [i][k] = t; } } } } else { for (k = 0; k < 4; k++) { for (l = k + 1; l < 4; l++) { if (z[i][l] < z[i][k]) { t = z [i][l]; z [i][l] = z[i][k]; z [i][k] = t; } } } } } for (j = 0; j < 4; j++) { if ((rand () % 2) == 0) { for (k = 0; k < 4; k++) { for (l = k + 1; l < 4; l++) { if (z[l][j] > z[k][j]) { t = z [l][j]; z [l][j] = z[k][j]; z [k][j] = t; } } } } else { for (k = 0; k < 4; k++) { for (l = k + 1; l < 4; l++) { if (z[l][j] < z[k][j]) { t = z [l][j]; z [l][j] = z[k][j]; z [k][j] = t; } } } } } } /* for (i = 0; i < 4; i++) { for (j = 0; j < 4; j++) printf ("%i ", z[i][j]); printf ("n"); } printf ("ZustandtEingabetAusgabetFolgezustandn"); for (i = 0; i < 4; i++) { for (j = 0; j < 4; j++) printf ("%itt%itt%itt%in", i, j, rand () % 4, z[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 (0) [state, thick] {0};n"); printf("\node (1) [state, thick, right of= 0] {1};n"); printf("\node (2) [state, thick, right of= 1] {2};n"); printf("\node (3) [state, thick, below of= 1] {3};nn"); printf("%Verbindungenn"); printf("\path[thick,->]n"); for (i = 0; i < 4; i++) { j = 0; if (z [i][j] == i) printf ("(%i) edge [loop above] node {%i/%i} (%i)n", i, j, rand () % 4, z[i][j]); else printf ("(%i) edge node {%i/%i} (%i)n", i, 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=15, bend left,below] node {%i/%i} (%i)n", i, j, rand () % 4, z[i][j]); /*j = 2; 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=15, bend right,below] node {%i/%i} (%i)n", i, j, rand () % 4, z[i][j]); j = 3; 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=15, bend left,above] node {%i/%i} (%i)n", i, j, rand () % 4, z[i][j]);*/ } /* printf("(1) edge node {1/0} (2)n"); printf("(1) edge [bend angle=15, bend left] node {0/0} (4)nn"); printf("(2) edge [bend angle=15, bend left,pos=0.4] node {0/0}(3)n"); printf("(2) edge node {1/0} (4)nn"); printf("(3) edge [bend angle=15, bend left,below] node {0/0} (2)n"); printf("(3) edge [bend angle=35, bend right, above] node {1/0} (1)nn"); printf("(4) edge [right] node {1/0} (3)n"); printf("(4) edge [bend angle=15, bend left] node {0/0} (1)n");*/ printf(";n"); printf("\end{tikzpicture}n"); printf("\end{center}n"); printf("\end{document}n"); return 0; }