|
- \documentclass[uebung]{../../../lecture}
-
- \usepackage{listings}
- \usetikzlibrary{positioning}
-
- \title{Übungsblatt 6}
- \author{Samuel Weidemaier, Christian Merten}
-
- \usepackage{xcolor}
-
- \lstdefinestyle{mystyle}{
- commentstyle=\color{gray},
- keywordstyle=\color{blue},
- numberstyle=\tiny\color{gray},
- stringstyle=\color{black},
- basicstyle=\ttfamily\footnotesize,
- breakatwhitespace=false,
- breaklines=true,
- captionpos=b,
- keepspaces=true,
- numbers=left,
- numbersep=5pt,
- showspaces=false,
- showstringspaces=false,
- showtabs=false,
- tabsize=2
- }
-
- \lstset{style=mystyle}
-
- \usepackage{tikz, wasysym}
- \usetikzlibrary{automata, positioning, arrows,shapes,shadows}
-
- \tikzstyle{abstract}=[rectangle, draw=black,
- %text centered,
- anchor=north, text=black, text width=15cm, rounded corners]
-
- \tikzstyle{subgroup}=[rectangle, draw=blue,
- %text centered,
- anchor=north, text=black, text width=3.5cm, rounded corners]
-
- \tikzstyle{myarrow}=[->, >=stealth, thick]
- \tikzstyle{gestrichen}=[->, >=stealth, dashed]
-
- \begin{document}
-
- \punkte
-
- \begin{aufgabe}
-
- \vspace{5mm}
- Marker 1:
- \vspace{-3mm}
- \begin{center}
- \begin{tikzpicture}[shorten >= 1pt, node distance=2.5cm, on grid, auto]
-
-
- \node[abstract, rectangle split, rectangle split parts=2] (global) {
- Globale Umgebung
- \nodepart{second}$g$ int $1$
- };
-
-
-
- \node[subgroup, rectangle split, rectangle split parts=2, below left of=global, xshift=-3.3cm, yshift=-0.3cm] (main) {
- main() \\
- \nodepart{second}
- $a$ int $2$ \\
- $b$ int $14$
- };
-
- \node[subgroup, rectangle split, rectangle split parts=2, below right of=main, yshift=-0.4cm] (block1) {
- Block $1$ in main() \\
- \nodepart{second}
- $a$ int $7$ \\
- $g$ int $?$
- };
-
- \node[subgroup, rectangle split, rectangle split parts=2, right of=block1, , xshift=2.1cm, yshift=-0.32cm] (ggTab) {
- ggT(b, a) \\
- \nodepart{second}
- $a$ int $14$ \\
- $b$ int $7$ \\
- Null int $0$
- };
-
-
-
- \node[subgroup, rectangle split, rectangle split parts=2, below right of=ggTab, yshift=-0.7cm] (amodb) {
- $a \text{ mod } b(a,b)$ \\
- \nodepart{second}
- $a$ int $14$ \\
- $b$ int $7$ \\
- $m$ int $0$
- };
-
-
- \draw[myarrow] (main.west) -- ++(0,0) -| ([xshift=-7.2cm] global.south);
-
- \draw[myarrow] (block1.west) -- ++(0,0) -| ([xshift=-1cm] main.south);
-
- \draw[gestrichen] ([xshift=-1.4cm] ggTab.south) -- ++(0,-0.4) -| (block1.south);
-
- \draw[myarrow] (ggTab.west) -- ++(0,0) -| ([xshift=-1cm] global.south);
-
-
- \draw[gestrichen] (amodb.west) -- ++(0,0) -| ([xshift=-1.7cm] ggTab);
-
- \draw[myarrow] ([xshift=1cm] amodb.north) -- ++(0,0) -| ([xshift=4.1cm] global.south);
-
-
-
- \end{tikzpicture}
-
- \vspace{-10mm}
-
- \end{center}
-
- \nopagebreak
-
- Marker 2:
- \vspace{-2mm}
- \begin{center}
- \begin{tikzpicture}[shorten >= 1pt, node distance=2.5cm, on grid, auto]
-
-
- \node[abstract, rectangle split, rectangle split parts=2] (global) {
- Globale Umgebung
- \nodepart{second}$g$ int $2$
- };
-
-
-
- \node[subgroup, rectangle split, rectangle split parts=2, below left of=global, xshift=-3.3cm, yshift=-0.3cm] (main) {
- main() \\
- \nodepart{second}
- $a$ int $2$ \\
- $b$ int $14$
- };
-
- \node[subgroup, rectangle split, rectangle split parts=2, below right of=main, yshift=-0.4cm] (block1) {
- Block $1$ in main() \\
- \nodepart{second}
- $a$ int $7$ \\
- $g$ int $?$
- };
-
- \node[subgroup, rectangle split, rectangle split parts=2, right of=block1, , xshift=2.1cm, yshift=-0.32cm] (ggTab) {
- ggT(b, a) \\
- \nodepart{second}
- $a$ int $14$ \\
- $b$ int $7$ \\
- Null int $0$
- };
-
- \node[subgroup, rectangle split, rectangle split parts=2, below right of=ggTab, , xshift=1cm, yshift=-0.7cm] (ggTmod) {
- $ggT(b, a \text{ mod }b(a,b))$ \\
- \nodepart{second}
- $a$ int $7$ \\
- $b$ int $0$ \\
- Null int $0$
- };
-
-
-
- \draw[myarrow] (main.west) -- ++(0,0) -| ([xshift=-7.2cm] global.south);
-
- \draw[myarrow] (block1.west) -- ++(0,0) -| ([xshift=-1cm] main.south);
-
- \draw[gestrichen] ([xshift=-1.4cm] ggTab.south) -- ++(0,-0.4) -| (block1.south);
-
- \draw[myarrow] (ggTab.west) -- ++(0,0) -| ([xshift=-1cm] global.south);
-
- \draw[gestrichen] (ggTmod.west) -- ++(0,0) -| (ggTab.south);
-
- \draw[myarrow] (ggTmod.north) -- ++(0,0) -| ([xshift=4.1cm] global.south);
-
-
-
- \end{tikzpicture}
-
- \end{center}
- Marker 3:
- \begin{center}
-
- \begin{tikzpicture}[shorten >= 1pt, node distance=2.5cm, on grid, auto]
-
-
- \node[abstract, rectangle split, rectangle split parts=2] (global) {
- Globale Umgebung
- \nodepart{second}$g$ int $2$
- };
-
-
-
- \node[subgroup, rectangle split, rectangle split parts=2, below left of=global, xshift=-3.3cm, yshift=-0.3cm] (main) {
- main() \\
- \nodepart{second}
- $a$ int $2$ \\
- $b$ int $7$
- };
-
-
- \draw[myarrow] (main.west) -- ++(0,0) -| ([xshift=-7.2cm] global.south);
-
-
-
- \end{tikzpicture}
- \end{center}
-
- \end{aufgabe}
-
- \newpage
-
- \begin{aufgabe} Primfaktorzerlegung
- \begin{lstlisting}[language=C++, title=Primfaktorzerlegung, captionpos=b]
- #include "cpp_headers/fcpp.hh"
-
- int main() {
- int n = enter_int("Please enter a natural number: ");
- // search smallest factor, start with smallest possible: 2
- int k=2;
- // go until sqrt(n)
- while (k <= sqrt(n)) {
- // k is factor of n
- if (n % k == 0) {
- // print out the factor k
- print(k);
- // reset n to the quotient
- n = n / k;
- // restart at k=2
- k = 2;
- } else {
- // if k is not a factor, check next one
- k++;
- }
- }
- // n is the last prime factor of the original input number
- print(n);
- }
- \end{lstlisting}
-
- Die algorithmische Komplexität des Programms für $n$ Primzahl ist $\sqrt{n}$, da die Schleife
- für Primzahlen bis $\sqrt{n} $ durchlaufen wird.
- \end{aufgabe}
-
- \begin{aufgabe}
- siehe \textit{taschenrechner.cpp}
-
- \end{aufgabe}
-
- \end{document}
|