#include <stdio.h> #include <stdlib.h> #include <time.h> #define MAX_SPECIAL_STATES 3 #define MAX_STATES 8 #define MIN_STATE 1 #define SPECIAL_STATE_1 1 #define SPECIAL_STATE_2 2 #define SPECIAL_STATE_3 3 #define MAX_INPUTS 2 int main (void) { time_t t; int i; int q [MAX_SPECIAL_STATES]; int j; int a [MAX_STATES]; int b [MAX_STATES]; int x [MAX_STATES]; srand ((int)time (\&t)); q [SPECIAL_STATE_1] = (rand () % MAX_STATES) + MIN_STATE; while ((q [SPECIAL_STATE_2] = ((rand () % MAX_SPECIAL_STATES)+MIN_STATE)) == q [SPECIAL_STATE_1]); while (((q [SPECIAL_STATE_3] = ((rand () % MAX_STATES)+MIN_STATE)) == q [SPECIAL_STATE_1]) || (q [SPECIAL_STATE_3] == q [SPECIAL_STATE_2])); j = rand () % MAX_INPUTS; printf ("Zur Sicherheit: %i %i %in", q [SPECIAL_STATE_1], q [SPECIAL_STATE_2], q [SPECIAL_STATE_3]); printf ("ZustandttFolge-Zustand fuertAusgangn"); printf ("tttx=0tx=1ttttn"); for (i = MIN_STATE; i < (MAX_STATES+MIN_STATE); i++) { if (i == q [SPECIAL_STATE_1]) { a [q [SPECIAL_STATE_1] - MIN_STATE] = q [SPECIAL_STATE_2]; b [q [SPECIAL_STATE_1] - MIN_STATE] = q [SPECIAL_STATE_3]; x [q [SPECIAL_STATE_1] - MIN_STATE] = j; } else if (i == q [SPECIAL_STATE_2]) { a [q [SPECIAL_STATE_2] - MIN_STATE] = q [SPECIAL_STATE_3], b [q [SPECIAL_STATE_2] - MIN_STATE] = q [SPECIAL_STATE_1]; x [q [SPECIAL_STATE_2] - MIN_STATE] = j; } else if (i == q [SPECIAL_STATE_3]) { a [q [SPECIAL_STATE_3] - MIN_STATE] = q [SPECIAL_STATE_1]; b [q [SPECIAL_STATE_3] - MIN_STATE] = q [SPECIAL_STATE_2]; x [q [SPECIAL_STATE_3] - MIN_STATE] = j; } else { a [i - MIN_STATE] = (rand () % MAX_STATES) + 1; b [i - MIN_STATE] = (rand () % MAX_STATES) + 1; x [i - MIN_STATE] = (rand () % MAX_INPUTS); } } for (i = MIN_STATE; i < (MAX_STATES + MIN_STATE); i++) printf ("%ittt%it%itttt%in", i - MIN_STATE, a [i - MIN_STATE], b [i - MIN_STATE], x [i - MIN_STATE]); return 0; }
// Gut ich habe von der Deep search jetzt erst Mal die Adjezensliste geschrieben #include <stdio.h> #include <stdlib.h> #include <time.h> #define MAX_STATES 128 #define MAX_INPUT 2 int main (void) { time_t t; int a [MAX_STATES]; int b [MAX_STATES]; int x [MAX_STATES]; int i; srand ((unsigned) time (\&t)); for (i = 0; i < MAX_STATES; i++) { a [i] = rand () % MAX_STATES; b [i] = rand () % MAX_STATES; x [i] = rand () % MAX_INPUT: } return 0; }
Ich meinte nicht vcard, sondern csv. Ich habe mich damit nie so recht beschäftigt und es wird an der zeit.
// So, ich bin mit meinem Programm schon weiter #include <stdio.h> #include <stdlib.h> #include <string.h> #include <time.h> #define MAX_SPECIAL_STATES 3 #define MAX_STATES 8 #define MIN_STATE 1 #define SPECIAL_STATE_1 1 #define SPECIAL_STATE_2 2 #define SPECIAL_STATE_3 3 #define MAX_INPUTS 2 void printraw (int a [], int b [], int x []) { int i; printf ("ZustandttFolge-Zustand fuertAusgangn"); printf ("tttx=0tx=1ttttn"); for (i = MIN_STATE; i < (MAX_STATES + MIN_STATE); i++) printf ("%ittt%it%itttt%in", i, a [i - MIN_STATE], b [i - MIN_STATE], x [i - MIN_STATE]); return; } void printcsv (int a [], int b [], int x []) { int i; printf ("Zustand,FolgeZustandx=0,FolgeZustandx=1,Ausgaben"); for (i = MIN_STATE; i < (MAX_STATES + MIN_STATE); i++) printf ("%i,%i,%i,%in", i, a [i - MIN_STATE], b [i - MIN_STATE], x [i - MIN_STATE]); return; } void readcsv (int a [], int b [], int x []) { int i; int j; scanf ("Zustand,FolgeZustandx=0,FolgeZustandx=1,Ausgaben"); for (i = MIN_STATE; i < (MAX_STATES + MIN_STATE); i++) { scanf ("%i,%i,%i,%in", \&j, \&a [i - MIN_STATE], \&b [i - MIN_STATE], \&x [i - MIN_STATE]); if (j != i) { fprintf (stderr, "IO-Errorn"); exit (1); } } return; } void createnew (int a [], int b [], int x []) { time_t t; int i; int q [MAX_SPECIAL_STATES]; int j; srand ((int)time (\&t)); q [SPECIAL_STATE_1] = (rand () % MAX_STATES) + MIN_STATE; while ((q [SPECIAL_STATE_2] = ((rand () % MAX_SPECIAL_STATES)+MIN_STATE)) == q [SPECIAL_STATE_1]); while (((q [SPECIAL_STATE_3] = ((rand () % MAX_STATES)+MIN_STATE)) == q [SPECIAL_STATE_1]) || (q [SPECIAL_STATE_3] == q [SPECIAL_STATE_2])); j = rand () % MAX_INPUTS; //printf ("Zur Sicherheit: %i %i %in", q [SPECIAL_STATE_1], q [SPECIAL_STATE_2], q [SPECIAL_STATE_3]); for (i = MIN_STATE; i < (MAX_STATES+MIN_STATE); i++) { if (i == q [SPECIAL_STATE_1]) { a [q [SPECIAL_STATE_1] - MIN_STATE] = q [SPECIAL_STATE_2]; b [q [SPECIAL_STATE_1] - MIN_STATE] = q [SPECIAL_STATE_3]; x [q [SPECIAL_STATE_1] - MIN_STATE] = j; } else if (i == q [SPECIAL_STATE_2]) { a [q [SPECIAL_STATE_2] - MIN_STATE] = q [SPECIAL_STATE_3], b [q [SPECIAL_STATE_2] - MIN_STATE] = q [SPECIAL_STATE_1]; x [q [SPECIAL_STATE_2] - MIN_STATE] = j; } else if (i == q [SPECIAL_STATE_3]) { a [q [SPECIAL_STATE_3] - MIN_STATE] = q [SPECIAL_STATE_1]; b [q [SPECIAL_STATE_3] - MIN_STATE] = q [SPECIAL_STATE_2]; x [q [SPECIAL_STATE_3] - MIN_STATE] = j; } else { a [i - MIN_STATE] = (rand () % MAX_STATES) + 1; b [i - MIN_STATE] = (rand () % MAX_STATES) + 1; x [i - MIN_STATE] = (rand () % MAX_INPUTS); } } } int main (int argc, char *argv []) { int a [MAX_STATES]; int b [MAX_STATES]; int x [MAX_STATES]; #define CREATE_NEW 0 #define READ_CSV 1 #define PRINT_RAW 0 #define PRINT_TEX 1 #define PRINT_CSV 2 #define PRINT_SOLVE 3 #define PRINT_TEX_STATE 3 #define PRINT_NO_HELP 0 #define PRINT_HELP 1 int argi; int createnew_readcsv = CREATE_NEW; int printraw_printtex_print_csv = PRINT_RAW; 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-raw", argv [argi]) == 0) || (strcmp ("-r", argv [argi]) == 0)) printraw_printtex_print_csv = PRINT_RAW; 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 ("--print-tex-state", argv [argi]) == 0) || (strcmp ("-x", argv [argi]) == 0)) printraw_printtex_print_csv = PRINT_TEX_STATE; if ((strcmp ("--solve", argv [argi]) == 0) || (strcmp ("-l", argv [argi]) == 0)) printraw_printtex_print_csv = PRINT_SOLVE; 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-rawn-snn"); printf ("--print-csvn-cnn"); printf ("--print-texn-tnn"); printf ("--helpn-hnn"); return 2; } if (createnew_readcsv == CREATE_NEW) createnew (a, b, x); else if (createnew_readcsv == READ_CSV) readcsv (a, b, x); if (printraw_printtex_print_csv == PRINT_RAW) printraw (a, b, x); else if (printraw_printtex_print_csv == PRINT_TEX); else if (printraw_printtex_print_csv == PRINT_CSV) printcsv (a, b, x); else if (printraw_printtex_print_csv == PRINT_TEX_STATE); else if (printraw_printtex_print_csv == PRINT_SOLVE); return 0; }
Zustand,FolgeZustandx=0,FolgeZustandx=1,Ausgabe 1,6,4,1 2,4,8,1 3,6,1,0 4,1,6,1 5,4,5,1 6,4,1,1 7,8,5,1 8,8,8,0
Zustand,FolgeZustandx=0,FolgeZustandx=1,Ausgabe 1,3,2,1 2,1,3,1 3,2,1,1 4,8,2,0 5,2,1,1 6,4,1,1 7,2,5,1 8,5,7,1
#include <stdio.h> #include <stdlib.h> #include <string.h> #include <time.h> #define MAX_SPECIAL_STATES 3 #define MAX_STATES 8 #define MIN_STATE 1 #define SPECIAL_STATE_1 1 #define SPECIAL_STATE_2 2 #define SPECIAL_STATE_3 3 #define MAX_INPUTS 2 void printraw (int a [], int b [], int x []) { int i; printf ("ZustandttFolge-Zustand fuertAusgangn"); printf ("tttx=0tx=1ttttn"); for (i = MIN_STATE; i < (MAX_STATES + MIN_STATE); i++) printf ("%ittt%it%itttt%in", i, a [i - MIN_STATE], b [i - MIN_STATE], x [i - MIN_STATE]); return; } void printcsv (int a [], int b [], int x []) { int i; printf ("Zustand,FolgeZustandx=0,FolgeZustandx=1,Ausgaben"); for (i = MIN_STATE; i < (MAX_STATES + MIN_STATE); i++) printf ("%i,%i,%i,%in", i, a [i - MIN_STATE], b [i - MIN_STATE], x [i - MIN_STATE]); return; } void printtex (int a [], int b [], int x []) { int i; printf ("\documentclass [a4paper]{article}n"); printf ("\usepackage{german}n"); printf ("\begin{document}n"); printf ("\begin{tabular}{|c||c|c||c|}"); n"); printf ("Zustand \& \multicolumn {2}{||c||}{Folge-Zustand fuer}\& Ausgangn"); n"); printf BITTE IM PDF NACHGUCKEN n"); n"); for (i = MIN_STATE; i < (MAX_STATES + MIN_STATE); i++) { printf ("%i \& %i \& %i \& %in", i, a [i - MIN_STATE], b [i - MIN_STATE], x [i - MIN_STATE]); n"); } printf ("\end{tabular}n"); printf ("\end{document}n"); return; } void readcsv (int a [], int b [], int x []) { int i; int j; scanf ("Zustand,FolgeZustandx=0,FolgeZustandx=1,Ausgaben"); for (i = MIN_STATE; i < (MAX_STATES + MIN_STATE); i++) { scanf ("%i,%i,%i,%in", \&j, \&a [i - MIN_STATE], \&b [i - MIN_STATE], \&x [i - MIN_STATE]); if (j != i) { fprintf (stderr, "IO-Errorn"); exit (1); } } return; } void createnew (int a [], int b [], int x []) { time_t t; int i; int q [MAX_SPECIAL_STATES]; int j; srand ((int)time (\&t)); q [SPECIAL_STATE_1] = (rand () % MAX_STATES) + MIN_STATE; while ((q [SPECIAL_STATE_2] = ((rand () % MAX_SPECIAL_STATES)+MIN_STATE)) == q [SPECIAL_STATE_1]); while (((q [SPECIAL_STATE_3] = ((rand () % MAX_STATES)+MIN_STATE)) == q [SPECIAL_STATE_1]) || (q [SPECIAL_STATE_3] == q [SPECIAL_STATE_2])); j = rand () % MAX_INPUTS; //printf ("Zur Sicherheit: %i %i %in", q [SPECIAL_STATE_1], q [SPECIAL_STATE_2], q [SPECIAL_STATE_3]); for (i = MIN_STATE; i < (MAX_STATES+MIN_STATE); i++) { if (i == q [SPECIAL_STATE_1]) { a [q [SPECIAL_STATE_1] - MIN_STATE] = q [SPECIAL_STATE_2]; b [q [SPECIAL_STATE_1] - MIN_STATE] = q [SPECIAL_STATE_3]; x [q [SPECIAL_STATE_1] - MIN_STATE] = j; } else if (i == q [SPECIAL_STATE_2]) { a [q [SPECIAL_STATE_2] - MIN_STATE] = q [SPECIAL_STATE_3], b [q [SPECIAL_STATE_2] - MIN_STATE] = q [SPECIAL_STATE_1]; x [q [SPECIAL_STATE_2] - MIN_STATE] = j; } else if (i == q [SPECIAL_STATE_3]) { a [q [SPECIAL_STATE_3] - MIN_STATE] = q [SPECIAL_STATE_1]; b [q [SPECIAL_STATE_3] - MIN_STATE] = q [SPECIAL_STATE_2]; x [q [SPECIAL_STATE_3] - MIN_STATE] = j; } else { a [i - MIN_STATE] = (rand () % MAX_STATES) + 1; b [i - MIN_STATE] = (rand () % MAX_STATES) + 1; x [i - MIN_STATE] = (rand () % MAX_INPUTS); } } } int main (int argc, char *argv []) { int a [MAX_STATES]; int b [MAX_STATES]; int x [MAX_STATES]; #define CREATE_NEW 0 #define READ_CSV 1 #define PRINT_RAW 0 #define PRINT_TEX 1 #define PRINT_CSV 2 #define PRINT_SOLVE 3 #define PRINT_TEX_STATE 3 #define PRINT_NO_HELP 0 #define PRINT_HELP 1 int argi; int createnew_readcsv = CREATE_NEW; int printraw_printtex_print_csv = PRINT_RAW; 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-raw", argv [argi]) == 0) || (strcmp ("-r", argv [argi]) == 0)) printraw_printtex_print_csv = PRINT_RAW; 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 ("--print-tex-state", argv [argi]) == 0) || (strcmp ("-x", argv [argi]) == 0)) printraw_printtex_print_csv = PRINT_TEX_STATE; if ((strcmp ("--solve", argv [argi]) == 0) || (strcmp ("-l", argv [argi]) == 0)) printraw_printtex_print_csv = PRINT_SOLVE; 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-rawn-snn"); printf ("--print-csvn-cnn"); printf ("--print-texn-tnn"); printf ("--helpn-hnn"); return 2; } if (createnew_readcsv == CREATE_NEW) createnew (a, b, x); else if (createnew_readcsv == READ_CSV) readcsv (a, b, x); if (printraw_printtex_print_csv == PRINT_RAW) printraw (a, b, x); else if (printraw_printtex_print_csv == PRINT_TEX) printtex (a, b, x); else if (printraw_printtex_print_csv == PRINT_CSV) printcsv (a, b, x); else if (printraw_printtex_print_csv == PRINT_TEX_STATE); else if (printraw_printtex_print_csv == PRINT_SOLVE); return 0; }
#include <stdio.h> #include <stdlib.h> #include <string.h> #include <time.h> #define MAX_SPECIAL_STATES 3 #define MAX_STATES 8 #define MIN_STATE 1 #define SPECIAL_STATE_1 1 #define SPECIAL_STATE_2 2 #define SPECIAL_STATE_3 3 #define MAX_INPUTS 2 void printraw (int a [], int b [], int x []) { int i; printf ("ZustandttFolge-Zustand fuertAusgangn"); printf ("tttx=0tx=1ttttn"); for (i = MIN_STATE; i < (MAX_STATES + MIN_STATE); i++) printf ("%ittt%it%itttt%in", i, a [i - MIN_STATE], b [i - MIN_STATE], x [i - MIN_STATE]); return; } void printcsv (int a [], int b [], int x []) { int i; printf ("Zustand,FolgeZustandx=0,FolgeZustandx=1,Ausgaben"); for (i = MIN_STATE; i < (MAX_STATES + MIN_STATE); i++) printf ("%i,%i,%i,%in", i, a [i - MIN_STATE], b [i - MIN_STATE], x [i - MIN_STATE]); return; } void printtex (int a [], int b [], int x []) { int i; printf ("\documentclass [a4paper]{article}n"); printf ("\usepackage{german}n"); printf ("\begin{document}n"); printf ("\begin{tabular}{|c||c|c||c|}"); n"); printf ("Zustand \& \multicolumn {2}{||c||}{Folge-Zustand fuer}\& Ausgangn"); n"); printf BITTE IM PDF NACHGUCKEN n"); n"); for (i = MIN_STATE; i < (MAX_STATES + MIN_STATE); i++) { printf ("%i \& %i \& %i \& %in", i, a [i - MIN_STATE], b [i - MIN_STATE], x [i - MIN_STATE]); n"); } printf ("\end{tabular}n"); printf ("\end{document}n"); return; } void printtexstate (int a [], int b [], int x []) { int i; int angle; printf ("\documentclass [a4paper]{article}n"); printf ("\usepackage{german}n"); printf ("\usepackage[utf8]{inputenc}n"); printf ("\usepackage{pgf, tikz}n"); printf ("\usetikzlibrary{arrows , automata , positioning}nn"); printf ("\begin{document}n"); printf ("\begin{tabular}{|c||c|c||c|}"); n"); printf ("Zustand \& \multicolumn {2}{||c||}{Folge-Zustand fuer}\& Ausgangn"); n"); printf BITTE IM PDF NACHGUCKEN n"); n"); for (i = MIN_STATE; i < (MAX_STATES + MIN_STATE); i++) { printf ("%i \& %i \& %i \& %in", i, a [i - MIN_STATE], b [i - MIN_STATE], x [i - MIN_STATE]); n"); } printf ("\end{tabular}n"); printf ("\begin{center}n"); printf ("\begin{tikzpicture}[>=stealth',shorten >=1pt,auto,node distance=2.5cm]n"); printf ("\node (%i) [state, thick] {%i/%i};n", MIN_STATE, MIN_STATE, x [MIN_STATE-1]); for (i = MIN_STATE+1; i < (MAX_STATES + MIN_STATE)-1; i+=2) { printf ("\node (%i) [state, thick, right of= %i] {%i/%i};n", i, i-1, i, x [i]); printf ("\node (%i) [state, thick, below of= %i] {%i/%i};n", i+1, i-1, i+1, x [i+1]); } printf ("\node (%i) [state, thick, right of= %i] {%i/%i};n", i, i-1, i, x [i]); printf ("nn\path[thick,->]n"); for (i = MIN_STATE, angle = 0; i < (MAX_STATES + MIN_STATE); i++, angle+=20) { printf ("(%i) [bend angle=%i, bend right, above] edge (%i)n", i, angle, a [i-1]); angle += 20; printf ("(%i) [bend angle=%i, bend left, below] edge (%i)n", i, angle, b [i-1]); } printf (";n"); printf ("\end{tikzpicture}n"); printf ("\end{center}n"); printf ("\end{document}n"); return; } void readcsv (int a [], int b [], int x []) { int i; int j; scanf ("Zustand,FolgeZustandx=0,FolgeZustandx=1,Ausgaben"); for (i = MIN_STATE; i < (MAX_STATES + MIN_STATE); i++) { scanf ("%i,%i,%i,%in", \&j, \&a [i - MIN_STATE], \&b [i - MIN_STATE], \&x [i - MIN_STATE]); if (j != i) { fprintf (stderr, "IO-Errorn"); exit (1); } } return; } void createnew (int a [], int b [], int x []) { time_t t; int i; int q [MAX_SPECIAL_STATES]; int j; srand ((int)time (\&t)); q [SPECIAL_STATE_1] = (rand () % MAX_STATES) + MIN_STATE; while ((q [SPECIAL_STATE_2] = ((rand () % MAX_SPECIAL_STATES)+MIN_STATE)) == q [SPECIAL_STATE_1]); while (((q [SPECIAL_STATE_3] = ((rand () % MAX_STATES)+MIN_STATE)) == q [SPECIAL_STATE_1]) || (q [SPECIAL_STATE_3] == q [SPECIAL_STATE_2])); j = rand () % MAX_INPUTS; //printf ("Zur Sicherheit: %i %i %in", q [SPECIAL_STATE_1], q [SPECIAL_STATE_2], q [SPECIAL_STATE_3]); for (i = MIN_STATE; i < (MAX_STATES+MIN_STATE); i++) { if (i == q [SPECIAL_STATE_1]) { a [q [SPECIAL_STATE_1] - MIN_STATE] = q [SPECIAL_STATE_2]; b [q [SPECIAL_STATE_1] - MIN_STATE] = q [SPECIAL_STATE_3]; x [q [SPECIAL_STATE_1] - MIN_STATE] = j; } else if (i == q [SPECIAL_STATE_2]) { a [q [SPECIAL_STATE_2] - MIN_STATE] = q [SPECIAL_STATE_3], b [q [SPECIAL_STATE_2] - MIN_STATE] = q [SPECIAL_STATE_1]; x [q [SPECIAL_STATE_2] - MIN_STATE] = j; } else if (i == q [SPECIAL_STATE_3]) { a [q [SPECIAL_STATE_3] - MIN_STATE] = q [SPECIAL_STATE_1]; b [q [SPECIAL_STATE_3] - MIN_STATE] = q [SPECIAL_STATE_2]; x [q [SPECIAL_STATE_3] - MIN_STATE] = j; } else { a [i - MIN_STATE] = (rand () % MAX_STATES) + MIN_STATE; b [i - MIN_STATE] = (rand () % MAX_STATES) + MIN_STATE; x [i - MIN_STATE] = (rand () % MAX_INPUTS); } } } int main (int argc, char *argv []) { int a [MAX_STATES]; int b [MAX_STATES]; int x [MAX_STATES]; #define CREATE_NEW 0 #define READ_CSV 1 #define PRINT_RAW 0 #define PRINT_TEX 1 #define PRINT_CSV 2 #define PRINT_SOLVE 3 #define PRINT_TEX_STATE 3 #define PRINT_NO_HELP 0 #define PRINT_HELP 1 int argi; int createnew_readcsv = CREATE_NEW; int printraw_printtex_print_csv = PRINT_RAW; 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-raw", argv [argi]) == 0) || (strcmp ("-r", argv [argi]) == 0)) printraw_printtex_print_csv = PRINT_RAW; 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 ("--print-tex-state", argv [argi]) == 0) || (strcmp ("-x", argv [argi]) == 0)) printraw_printtex_print_csv = PRINT_TEX_STATE; if ((strcmp ("--solve", argv [argi]) == 0) || (strcmp ("-l", argv [argi]) == 0)) printraw_printtex_print_csv = PRINT_SOLVE; 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-rawn-snn"); printf ("--print-csvn-cnn"); printf ("--print-texn-tnn"); printf ("--helpn-hnn"); return 2; } if (createnew_readcsv == CREATE_NEW) createnew (a, b, x); else if (createnew_readcsv == READ_CSV) readcsv (a, b, x); if (printraw_printtex_print_csv == PRINT_RAW) printraw (a, b, x); else if (printraw_printtex_print_csv == PRINT_TEX) printtex (a, b, x); else if (printraw_printtex_print_csv == PRINT_CSV) printcsv (a, b, x); else if (printraw_printtex_print_csv == PRINT_TEX_STATE) printtexstate (a, b, x); else if (printraw_printtex_print_csv == PRINT_SOLVE); return 0; }
0 0 0 0 0 0 1 0 0 0 1 1 2 0 0 1 0 1 3 0 0 1 1 0 4 0 1 0 0 0 5 0 1 0 1 0 6 0 1 1 0 1 7 0 1 1 1 1 8 1 0 0 0 0 9 1 0 0 1 0 10 1 0 1 0 1 11 1 0 1 1 1 12 1 1 0 0 1 13 1 1 0 1 1 14 1 1 1 0 1 15 1 1 1 1 0 1 0 0 0 1 1 2 0 0 1 0 1 6 0 1 1 0 1 7 0 1 1 1 1 10 1 0 1 0 1 11 1 0 1 1 1 12 1 1 0 0 1 13 1 1 0 1 1 14 1 1 1 0 1 Gruppe 1: 1 0 0 0 1 1 2 0 0 1 0 1 Gruppe 2: 6 0 1 1 0 1 10 1 0 1 0 1 12 1 1 0 0 1 Gruppe 3: 7 0 1 1 1 1 11 1 0 1 1 1 13 1 1 0 1 1 14 1 1 1 0 1 1 0 0 0 1 2:6 0 - 1 0 2:10 - 0 1 0 6:7 0 1 1 - 6:14 - 1 1 0 10:11 1 0 1 - 10:14 1 - 1 0 12:13 1 1 0 - 12:14 1 1 - 0 1 0 0 0 1 2:10 - 0 1 0 6:14 - 1 1 0 2:6 0 - 1 0 10:14 1 - 1 0 12:14 1 1 - 0 6:7 0 1 1 - 10:11 1 0 1 - 12:13 1 1 0 - 1 0 0 0 1 Gruppe 1: 2:10 - 0 1 0 Gruppe 2: 6:14 - 1 1 0 Gruppe 1: 2:6 0 - 1 0 Gruppe 2: 10:14 1 - 1 0 12:14 1 1 - 0 Gruppe 2: 6:7 0 1 1 - 10:11 1 0 1 - 12:13 1 1 0 - 1 0 0 0 1 Gruppe 1: 2:10 - 0 1 0 Gruppe 2: 6:14 - 1 1 0 2:10:6:14 - - 1 0 Gruppe 1: 2:6 0 - 1 0 Gruppe 2: 10:14 1 - 1 0 2:6:10:14 - - 1 0 12:14 1 1 - 0 Gruppe 2: 6:7 0 1 1 - 10:11 1 0 1 - 12:13 1 1 0 - 1 0 0 0 1 2:10:6:14 - - 1 0 12:14 1 1 - 0 6:7 0 1 1 - 10:11 1 0 1 - 12:13 1 1 0 - 1 2 6 7 10 11 12 13 14 1 * 2:10:6:14 * * * * 12:14 * * 6:7 * * 10:11 * * 12:13 * * 1 2 6 7 10 11 12 13 14 1 * 2:10:6:14 * * * * 6:7 * * 10:11 * * 12:13 * * 1 0 0 0 1 2:10:6:14 - - 1 0 6:7 0 1 1 - 10:11 1 0 1 - 12:13 1 1 0 - y <= (not x3 and not x2 and not x1 and x0) or (x1 and not x0) or (not x3 and x2 and x1) or (x3 and not x2 and x1) or (x3 and x2 and not x1) y <= not ( (x3 or x2 or x1 or not x0) and (not x1 or x0) and (x3 or not x2 or not x1) and (not x3 or x2 or not x1) and (not 3 or not x2 or x1) ); library ieee; use ieee.std_logic_1164.all; entity quine20240205 is port ( x3, x2, x1, x0: in std_logic; y: out std_logic ); end; architecture behaviour of quine20240205 is begin y <= (not x3 and not x2 and not x1 and x0) or (x1 and not x0) or (not x3 and x2 and x1) or (x3 and not x2 and x1) or (x3 and x2 and not x1); end; library ieee; use ieee.std_logic_1164.all; entity quine20240205testbench is port ( y: out std_logic ); end; architecture behaviour of quine20240205testbench is component quine20240205 port ( x3, x2, x1, x0: in std_logic; y: out std_logic ); end component; signal x3, x2, x1, x0: std_logic; begin q: quine20240205 PORT MAP (x3=>x3, x2=>x2, x1=>x1, x0=>x0, y=>y); x0 <= '0' after 0 ns, '1' after 10 ns, '0' after 20 ns, '1' after 30 ns, '0' after 40 ns, '1' after 50 ns, '0' after 60 ns, '1' after 70 ns, '0' after 80 ns, '1' after 90 ns, '0' after 100 ns, '1' after 110 ns, '0' after 120 ns, '1' after 130 ns, '0' after 140 ns, '1' after 150 ns; x1 <= '0' after 0 ns, '0' after 10 ns, '1' after 20 ns, '1' after 30 ns, '0' after 40 ns, '0' after 50 ns, '1' after 60 ns, '1' after 70 ns, '0' after 80 ns, '0' after 90 ns, '1' after 100 ns, '1' after 110 ns, '0' after 120 ns, '0' after 130 ns, '1' after 140 ns, '1' after 150 ns; x2 <= '0' after 0 ns, '0' after 10 ns, '0' after 20 ns, '0' after 30 ns, '1' after 40 ns, '1' after 50 ns, '1' after 60 ns, '1' after 70 ns, '0' after 80 ns, '0' after 90 ns, '0' after 100 ns, '0' after 110 ns, '1' after 120 ns, '1' after 130 ns, '1' after 140 ns, '1' after 150 ns; x3 <= '0' after 0 ns, '0' after 10 ns, '0' after 20 ns, '0' after 30 ns, '0' after 40 ns, '0' after 50 ns, '0' after 60 ns, '0' after 70 ns, '1' after 80 ns, '1' after 90 ns, '1' after 100 ns, '1' after 110 ns, '1' after 120 ns, '1' after 130 ns, '1' after 140 ns, '1' after 150 ns; end;
library ieee; use ieee.std_logic_1164.all; entity quine20240205 is port ( x3, x2, x1, x0: in std_logic; y: out std_logic ); end; architecture behaviour of quine20240205 is begin y <= (not x3 and not x2 and not x1 and x0) or (x1 and not x0) or (not x3 and x2 and x1) or (x3 and not x2 and x1) or (x3 and x2 and not x1); end; library ieee; use ieee.std_logic_1164.all; entity quine20240205testbench is port ( y: out std_logic ); end; architecture behaviour of quine20240205testbench is component quine20240205 port ( x3, x2, x1, x0: in std_logic; y: out std_logic ); end component; signal x3, x2, x1, x0: std_logic; begin q: quine20240205 PORT MAP (x3=>x3, x2=>x2, x1=>x1, x0=>x0, y=>y); x0 <= '0' after 0 ns, '1' after 10 ns, '0' after 20 ns, '1' after 30 ns, '0' after 40 ns, '1' after 50 ns, '0' after 60 ns, '1' after 70 ns, '0' after 80 ns, '1' after 90 ns, '0' after 100 ns, '1' after 110 ns, '0' after 120 ns, '1' after 130 ns, '0' after 140 ns, '1' after 150 ns; x1 <= '0' after 0 ns, '0' after 10 ns, '1' after 20 ns, '1' after 30 ns, '0' after 40 ns, '0' after 50 ns, '1' after 60 ns, '1' after 70 ns, '0' after 80 ns, '0' after 90 ns, '1' after 100 ns, '1' after 110 ns, '0' after 120 ns, '0' after 130 ns, '1' after 140 ns, '1' after 150 ns; x2 <= '0' after 0 ns, '0' after 10 ns, '0' after 20 ns, '0' after 30 ns, '1' after 40 ns, '1' after 50 ns, '1' after 60 ns, '1' after 70 ns, '0' after 80 ns, '0' after 90 ns, '0' after 100 ns, '0' after 110 ns, '1' after 120 ns, '1' after 130 ns, '1' after 140 ns, '1' after 150 ns; x3 <= '0' after 0 ns, '0' after 10 ns, '0' after 20 ns, '0' after 30 ns, '0' after 40 ns, '0' after 50 ns, '0' after 60 ns, '0' after 70 ns, '1' after 80 ns, '1' after 90 ns, '1' after 100 ns, '1' after 110 ns, '1' after 120 ns, '1' after 130 ns, '1' after 140 ns, '1' after 150 ns; end;
Ich höre jetzt auf, weil es strategisch für heute abend der richtige Schritt es ist, es gut sein zu lassen.
Zustand Folge-Zustand fuer Ausgang x=0 x=1 1 8 2 0 2 1 8 0 3 6 5 0 4 2 6 0 5 1 3 1 6 5 3 1 7 5 7 0 8 2 1 0 Zustand Folge-Zustand fuer Ausgang x=0 x=1 1 8 2 0 2 1 8 0 3 6 5 0 4 2 6 0 7 5 7 0 8 2 1 0 (1,2) (8,1) (2,8) (1,3) (8,6) (2,5) (1,4) (8,2) (2,6) (1,7) (8,5) (2,7) (1,8) (8,2) (2,1) (2,3) (1,6) (8,5) (2,4) (1,2) (8,6) (2,7) (1,5) (8,7) (2,8) (1,2) (8,1) (3,4) (6,2) (5,6) (3,7) (6,5) (5,7) (3,8) (6,2) (5,1) (4,7) (2,5) (5,7) (4,8) (2,2) (6,1) (7,8) (5,2) (7,1) Zustand Folge-Zustand fuer Ausgang x=0 x=1 5 1 3 1 6 5 3 1 (5,6) (1,5) (3,3) (1,2) (8,1) (2,8) (1,3) (8,6) (2,5) (1,4) (8,2) (2,6) (1,7) (8,5) (2,7) (1,8) (8,2) (2,1) (2,3) (1,6) (8,5) (2,4) (1,2) (8,6) (2,7) (1,5) (8,7) (2,8) (1,2) (8,1) (3,4) (6,2) (5,6) (3,7) (6,5) (5,7) (3,8) (6,2) (5,1) (4,7) (2,5) (5,7) (4,8) (2,2) (6,1) (5,6) (1,5) (3,3) (7,8) (5,2) (7,1) (1,2) (1,8) (2,8) (1,3) (6,8) (2,5) (1,4) (2,8) (2,6) (1,7) (5,8) (2,7) (1,8) (2,8) (1,2) (2,3) (1,6) (5,8) (2,4) (1,2) (6,8) (2,7) (1,5) (7,8) (2,8) (1,2) (1,8) (3,4) (2,6) (5,6) (3,7) (5,6) (5,7) (3,8) (2,6) (1,5) (4,7) (2,5) (5,7) (4,8) (2,2) (1,6) (5,6) (1,5) (3,3) (7,8) (2,5) (1,7) (1,2) (1,8) (2,8) (1,3) (6,8) (2,5) (1,4) (2,8) (2,6) (1,7) (5,8) (2,7) (1,8) (2,8) (1,2) (2,3) (1,6) (5,8) (2,4) (1,2) (6,8) (2,7) (1,5) (7,8) (2,8) (1,2) (1,8) (3,4) (2,6) (5,6) (3,7) (5,6) (5,7) (3,8) (2,6) (1,5) (4,7) (2,5) (5,7) (4,8) (2,2) (1,6) (5,6) (1,5) (7,8) (2,5) (1,7) (1,2) (1,8) (2,8) --(1,3) --(6,8) (2,5) --(1,4) (2,8) --(2,6) --(1,7) --(5,8) (2,7) (1,8) (2,8) (1,2) --(2,3) --(1,6) (5,8) --(2,4) (1,2) --(6,8) --(2,7) --(1,5) (7,8) (2,8) (1,2) (1,8) --(3,4) --(2,6) (5,6) --(3,7) (5,6) --(5,7) --(3,8) --(2,6) (1,5) --(4,7) --(2,5) (5,7) --(4,8) --(1,6) --(5,6) --(1,5) --(7,8) --(2,5) (1,7) (1,2) (1,8) (2,8) (1,8) (2,8) (1,2) (2,8) (1,2) (1,8) Perfekt
Ok, da ist was bei MUL falsch berechnet 1.) Rechne die Zahl in binaer Darstellung in eine Dezimale Darstellung um 0111000100000010b 28930d 0 2\^15 1 2\^14 2\^14 1 2\^13 2\^13 1 2\^12 2\^12 0 2\^11 0 2\^10 0 2\^9 1 2\^8 2\^8 0 2\^7 0 2\^6 0 2\^5 0 2\^4 0 2\^3 0 2\^2 1 2\^1 2\^1 0 2\^0 2\^14+2\^13+2\^12+2\^8+2\^1 8192+8192+8192+4096+256+2 8192 8192 8192 4096 256 2 42 --------- 28930 2.) Rechne die Zahl in dezimal darstellung in eine Binaerdarstellung um 47779 1011101010100011 47779 / 2 = 20000 + (7780-1)/2 = 20000 + (3500 + 350 + 40/2) 2 Rest 1 = 23839 -2 = 23849 Rest 1 47780 / 2 20000 + 40 + 350 + 3500 20000 3500 350 40 ----- 23890 -1 23889 23889 111 ------ 47778 47779 / 2 = 23889 Rest 1 23889 / 2 = 10000 + 1500 + 400 + 44 Rest 1 20000 1500 400 44 ----- 21944 11944 11944 ----- 23888 Rest 1 47779 / 2 = 23889 Rest 1 23889 / 2 = 11944 Rest 1 11944 / 2 = 5000 + 500 + 450 + 22 5000 500 450 22 ---- 5972 5972 5972 11 ---- 11944 47779 / 2 = 23889 Rest 1 23889 / 2 = 11944 Rest 1 11944 / 2 = 5972 Rest 0 5972 / 2 = 5972 / 2 = 2500 + 450 + 35 1 ------ 2986 2986 2986 111 ---- 5972 47779 / 2 = 23889 Rest 1 23889 / 2 = 11944 Rest 1 11944 / 2 = 5972 Rest 0 5972 / 2 = 2986 Rest 0 2986 / 2 = 1493 Rest 0 1493 / 2 = 746 Rest 1 746 / 2 = 373 Rest 0 373 / 2 = 186 Rest 1 186 / 2 = 93 Rest 0 93 / 2 = 46 Rest 1 46 / 2 = 23 Rest 0 23 / 2 = 11 Rest 1 11 / 2 = 5 Rest 1 5 / 2 = 2 Rest 1 2 / 2 = 1 Rest 0 1 / 2 = 0 Rest 1 1011101010100011 1011101010100011b 1000 450 40 3 ---- 1493 1493 1493 1 ---- 2986 1493 / 2 = 700 + 45 + 1 373 373 1 --- 746 373 = 150 + 35 + 1 186 186 11 ---- 372 1011101010100011b 3.) Addiere die drei Zahlen schriftlich 18469 + 21688 + 9001 ----------------- 40157 18469 21688 9001 111 _---------------- 40158 4.) Subtrahiere die letzten drei Zahlen schriftlich von der ersten schriftlich 53341 - 3790 - 6484 - 2299 ----------------- 40768 53341 - 3790 - 6484 - 2299 121 1 ----------------- 41878 Muss sp"ater korrigiert werden 5.) Rechne die Zahl ins zweier komplement um, mit 8 Bit - und subtrahiere diese zahl von der ersten und rechne das Ergebnis nach dezimal -36 -83 = -119 11011100 10101101 = 10001001 6.) Multipliziere die zwei Zahlen schriftlich 775502494*38517 = 2826985014 2316507382 38517*775502494 = 2826985014 2316507382 Taschenrechner, sagt: 2326507482 38517*775502494 = 2326507482 + 6204019952 + 3877512470 2326507482 6204019952 3877512470 775502494 5428517458 23265074820000 6204019952000 387751247000 77550249400 5428517458 775502494 775502494 775502494 21 111 --------- 2316507382 7.) Dividiere die zwei Zahlen schriftlich 1528000101/5836 = 261823 8.) Errechne x Logarithmisch mit dem Taschenrechner 58843\^x = 2091390428