diff --git a/20151119/Tower_of_Hanoi.jpeg b/20151119/Tower_of_Hanoi.jpeg new file mode 120000 index 0000000000000000000000000000000000000000..a1a794afda08596ffa2f46f278db53455de25b6c --- /dev/null +++ b/20151119/Tower_of_Hanoi.jpeg @@ -0,0 +1 @@ +../common/Tower_of_Hanoi.jpeg \ No newline at end of file diff --git a/20151119/ainf-20151119.pdf b/20151119/ainf-20151119.pdf new file mode 100644 index 0000000000000000000000000000000000000000..b92b2e5bec937142c1366714b4d6a31f610c33b4 Binary files /dev/null and b/20151119/ainf-20151119.pdf differ diff --git a/20151119/ainf-20151119.tex b/20151119/ainf-20151119.tex new file mode 100644 index 0000000000000000000000000000000000000000..679ceed16f226e4b974d24b89552c2d2b067ec65 --- /dev/null +++ b/20151119/ainf-20151119.tex @@ -0,0 +1,536 @@ +% ainf-20151119.pdf - Lecture Slides on Applied Computer Sciences +% Copyright (C) 2012, 2013, 2015 Peter Gerwinski +% +% This document is free software: you can redistribute it and/or +% modify it either under the terms of the Creative Commons +% Attribution-ShareAlike 3.0 License, or under the terms of the +% GNU General Public License as published by the Free Software +% Foundation, either version 3 of the License, or (at your option) +% any later version. +% +% This document is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with this document. If not, see <http://www.gnu.org/licenses/>. +% +% You should have received a copy of the Creative Commons +% Attribution-ShareAlike 3.0 Unported License along with this +% document. If not, see <http://creativecommons.org/licenses/>. + +\documentclass[10pt,t]{beamer} + +\usepackage{pgslides} +\usepackage{pdftricks} + +\newrgbcolor{orange}{0.7 0.2 0.0} + +\begin{psinputs} + \usepackage[latin1]{inputenc} + \usepackage[german]{babel} + \usepackage[T1]{fontenc} + \usepackage{helvet} + \renewcommand*\familydefault{\sfdefault} + \usepackage{pstricks,pst-grad} +\end{psinputs} + +\title{Angewandte Informatik} +\author{Prof.\ Dr.\ rer.\ nat.\ Peter Gerwinski} +\date{19.\ November 2015} + +\begin{document} + +\maketitleframe + +\begin{frame} + \textbf{Sie können diese Vortragsfolien + einschließlich Beispielprogramme, Skript und sonstiger Lehrmaterialien + unter} + \begin{center} + \url{https://gitlab.cvh-server.de/pgerwinski/ainf.git} + \end{center} + \textbf{herunterladen.} + + \bigskip + + \begin{onlyenv}<1> + \begin{itemize} + \arrowitem + \textbf{\color{blue}Files}\\ + einzelne Dateien herunterladen + \arrowitem + \textbf{\color{blue}Download zip/tar.gz/tar.bz2/tar}\\ + als Archiv herunterladen + \arrowitem + \url{https://gitlab.cvh-server.de/pgerwinski/ainf.git}\\ + mit GIT herunterladen und synchronisieren + \end{itemize} + \end{onlyenv} + + \begin{onlyenv}<2> + Achtung: Einige Dateien sind \newterm{Symlinks} -- symbolische Verknüpfungen! + \begin{itemize} + \item + Verweis auf eine andere Datei + \item + hier: Verweis auf gemeinsame Datei im Verzeichnis \file{common} + \item + Web-Interface zeigt Dateinamen als Text (statt Dateiinhalt) + \item + Beispiel: \file{earth-texture.rgb}\\ + \textarrow\ Textdatei mit Inhalt "`\file{../common/earth-texture.rgb}"'\\ + \textarrow\ bei Verwendung: keine Fehlermeldung, aber keine Textur + \item + Beim Herunterladen als Archiv-Datei (zip/tar.gz/tar.bz2/tar)\\ + sind die Symlinks darin korrekt gespeichert. + \item + ebenfalls korrekt:\\ + \file{git clone https://gitlab.cvh-server.de/pgerwinski/ainf.git} + \end{itemize} + \end{onlyenv} +\end{frame} + +\sectionnonumber{Ergänzungen} +\subsectionnonumber{OpenGL} + +\begin{frame} + + \showsectionnonumber + \showsubsectionnonumber + + \begin{itemize} + \item + \textbf{Doppelte Pufferung}\\ + 2 "`Bildschirme"': einer zum Zeichnen; einer wird angezeigt\\ + \file{opengl-magic.double.c}, \lstinline{gluSwapBuffers()} + \pause + \item + \textbf{Im Display-Handler} (\lstinline{draw()}) \textbf{wirklich nur zeichnen!}\\ + Wir haben nicht unter Kontrolle, wann, wie oft oder ob überhaupt\\ + diese Funktion aufgerufen wird. + \end{itemize} + +\end{frame} + +\subsectionnonumber{Umgang mit Bibliotheken} + +\begin{frame}[fragile] + + \showsectionnonumber + \showsubsectionnonumber + + \begin{itemize} + \item + \textbf{Separates Compilieren}\\ + \begin{lstlisting}[style=terminal,gobble=8] + $ ¡gcc -c -Wall opengl-magic.c¿ + $ ¡gcc -c -Wall textured-spheres.c¿ + $ ¡gcc -Wall orbit-x.c -lGL -lGLU -lglut \ + opengl-magic.o textured-spheres.o -o orbit-x¿ + \end{lstlisting} + \pause + \item + Die \textbf{Link-Reihenfolge} kann eine Rolle spielen!\\ + \begin{lstlisting}[style=terminal,gobble=8] + $ ¡gcc -Wall orbit-x.c \ + opengl-magic.o textured-spheres.o \ + -lGL -lGLU -lglut -o orbit-x¿ + \end{lstlisting} + Notfalls: + \begin{lstlisting}[style=terminal,gobble=8] + $ ¡gcc -Wall orbit-x.c -lGL -lGLU -lglut \ + opengl-magic.o textured-spheres.o \ + -lGL -lGLU -lglut -o orbit-x¿ + \end{lstlisting} + \end{itemize} + +\end{frame} + +\subsectionnonumber{Parameter des Hauptprogramms} + +\begin{frame}[fragile] + + \showsectionnonumber + \showsubsectionnonumber + + \medskip + + \begin{lstlisting} + int main (int argc, char **argv) + { + init_opengl (&argc, argv, "Orbit"); + ... + return 0; + } + \end{lstlisting} + +\end{frame} + +\begin{frame}[fragile] + \showsectionnonumber + \showsubsectionnonumber + + \medskip + + \begin{lstlisting} + #include <stdio.h> + + int main (int argc, char **argv) + { + printf ("argc = %d\n", argc); + for (int i = 0; i < argc; i++) + printf ("argv[%d] = \"%s\"\n", i, argv[i]); + return 0; + } + \end{lstlisting} + +\end{frame} + +\sectionnonumber{\inserttitle} + +\begin{frame} + + \showsectionnonumber + + \begin{itemize} + \item[\textbf{1}] \textbf{Einführung} + \item[\textbf{2}] \textbf{Einführung in C} + \item[\textbf{3}] \textbf{Bibliotheken} + \begin{itemize} + \item[3.1] Der Präprozessor + \item[3.2] Bibliotheken einbinden + \item[3.3] Bibliothek verwenden (Beispiel: OpenGL) + \item[3.4] Projekt organisieren: make + \end{itemize} + \item[\textbf{4}] \textbf{Algorithmen} + \begin{itemize} + \color{medgreen} + \item[4.1] Differentialgleichungen + \color{red} + \item[4.2] Rekursion + \item[4.3] Stack und FIFO + \color{black} + \item[4.4] Aufwandsabschätzungen + \end{itemize} + \color{gray} + \item[\textbf{5}] \textbf{Hardwarenahe Programmierung} + \item[\makebox(0,0){\textbf{\raisebox{0.5ex}{\dots}}}] +% \item[\textbf{6}] \textbf{Ergänzungen und Ausblicke} + \end{itemize} + +\end{frame} + +\section{Einführung} +\section{Einführung in C} +\section{Bibliotheken} + +\section{Algorithmen} +\subsection{Differentialgleichungen} + +\begin{frame}[fragile] + \showsection + \showsubsection + + \vspace*{-\bigskipamount} + + \begin{eqnarray*} + \varphi'(t) &=& \omega(t) \\[\medskipamount] + \omega'(t) &=& -\frac{g}{l}\cdot\sin\varphi(t)\hspace*{7.1cm} + \end{eqnarray*} + + \begin{itemize} + \item + Von Hand (analytisch): Lösung raten (Ansatz), Parameter berechnen + \item + Mit Computer (numerisch): Eulersches Polygonzugverfahren + \end{itemize} + + \medskip + + \begin{lstlisting}[gobble=0] + phi += dt * omega; + omega += - dt * g / l * sin (phi); + \end{lstlisting} + + \bigskip + + Praktikumsaufgabe: Umlaufbahn + +\end{frame} + +\subsection{Rekursion} + +\begin{frame}[fragile] + + \showsubsection + + Vollständige Induktion: + \vspace*{-0.725cm} + \begin{displaymath} + \hspace*{4cm} + \left. + \begin{array}{r} + \mbox{Aussage gilt für $n = 1$}\\[2pt] + \mbox{Schluß von $n - 1$ auf $n$} + \end{array} + \right\} + \mbox{Aussage gilt für alle $n\in\mathbb{N}$} + \end{displaymath} + \vspace*{-0.5cm} + + \pause + + Türme von Hanoi + + \begin{onlyenv}<2> + \begin{center} + \includegraphics[width=12.2cm]{Tower_of_Hanoi.jpeg} + \end{center} + \end{onlyenv} + + \begin{onlyenv}<3-> + \begin{itemize} + \item + 64 Scheiben, 3 Plätze, + \only<3-4>{\hfill\makebox(0,0)[rt]{\includegraphics[width=6cm]{Tower_of_Hanoi.jpeg}}}\\ + immer 1 Scheibe verschieben + \item + Ziel: Turm verschieben + \item + Es dürfen nur kleinere Scheiben\\ + auf größeren liegen. + \bigskip + \pause + \pause + \item + $n = 1$ Scheibe: fertig + \item + Wenn $n - 1$ Scheiben verschiebbar:\\ + schiebe $n - 1$ Scheiben auf Hilfsplatz,\\ + verschiebe die darunterliegende,\\ + hole $n - 1$ Scheiben von Hilfsplatz + \end{itemize} + \pause + \vspace{-4.3cm} + \begin{lstlisting}[gobble=6,xleftmargin=6.2cm] + void verschiebe (int n, int start, int ziel) + { + if (n == 1) + verschiebe_1_scheibe (start, ziel); + else + { + verschiebe (1, start, hilfsplatz); + verschiebe (n - 1, start, ziel); + verschiebe (1, hilfsplatz, ziel); + } + } + \end{lstlisting} + \end{onlyenv} + +\end{frame} + +\begin{frame}[fragile] + + \showsubsection + + \begin{minipage}[t]{6cm} + \vspace*{0.5cm} + Floodfill\strut\\ + \begin{lstlisting}[gobble=6] + void fill (int x, int y, char c, char o) + { + if (get_point (x, y) == o) + { + put_point (x, y, c); + fill (x + 1, y, c, o); + fill (x - 1, y, c, o); + fill (x, y + 1, c, o); + fill (x, y - 1, c, o); + } + } + \end{lstlisting} + \end{minipage}\pause + \begin{minipage}[t]{6.3cm} + \vspace*{-1cm} + Aufgabe: Schreiben Sie eine\\ + Bibliothek für "`Text-Grafik"'\\ + mit folgenden Funktionen: + \begin{itemize} + \item + \lstinline|void clear (char c)|\\ + Bildschirm auf Zeichen \lstinline|c| löschen + \item + \lstinline|void put_point (int x, int y, char c)|\\ + Punkt setzen + \item + \lstinline|char get_point (int x, int y)|\\ + Punkt lesen + \item + \lstinline|void fill (int x, int y, char c, char o)|\\ + Fläche in der "`Farbe"' \lstinline|o|,\\ + die den Punkt \lstinline|(x, y)| enthält,\\ + mit der "`Farbe"' \lstinline|c| ausmalen + \item + \lstinline|void display (void)|\\ + Inhalt des Arrays auf dem\\ + Bildschirm ausgeben + \end{itemize} + Hinweis: Verwenden Sie ein\\Array als "`Bildschirm"'. + \end{minipage} + +\end{frame} + +\begin{frame}[fragile] + + \showsubsection + + Ausgabe einer Hex-Zahl\strut\\ + \begin{itemize} + \item + Den Rest der Zahl bei Division durch 16 ausgeben, \dots + \item + \dots\ \emph{aber vorher\/} die Hex-Ziffern der durch 16 dividierten Zahl ausgeben. + \pause + \arrowitem + Array als Zwischenspeicher zum Umdrehen entfällt. + \pause + \arrowitem + \emph{Wirklich?} + \end{itemize} + +\end{frame} + +\subsection{Stack und FIFO} + +\begin{frame}[fragile] + + \showsubsection + + \bigskip + + \begin{minipage}[b]{6cm} + \begin{center} + "`First In -- First Out"' + + \bigskip + + \begin{picture}(6,4) + \thicklines + \color{structure} + \put(0.5,0){\line(1,0){5}} + + \put(3.5,0){\only<1-5>{\line(0,1){1}}} + \put(4.5,0){\only<1-4>{\line(0,1){1}}} + \put(3.5,1){\only<1-4>{\line(1,0){1}}} + \put(4.0,0.5){\only<1-4>{\makebox(0,0){\lstinline{3}}}} + \put(3.0,1.5){\only<1>{\vector(1,-1){0.45}}} + \put(3.0,1.5){\only<1>{\makebox(0,0)[b]{\lstinline{push (3)}}}} + + \put(2.5,0){\only<2-6>{\line(0,1){1}}} + \put(2.5,1){\only<2-5>{\line(1,0){1}}} + \put(3.0,0.5){\only<2-5>{\makebox(0,0){\lstinline{7}}}} + \put(2.0,1.5){\only<2>{\vector(1,-1){0.45}}} + \put(2.0,1.5){\only<2>{\makebox(0,0)[b]{\lstinline{push (7)}}}} + + \put(1.5,0){\only<3-6>{\line(0,1){1}}} + \put(1.5,1){\only<3-6>{\line(1,0){1}}} + \put(2.0,0.5){\only<3-6>{\makebox(0,0){\lstinline{137}}}} + \put(1.0,1.5){\only<3>{\vector(1,-1){0.45}}} + \put(1.0,1.5){\only<3>{\makebox(0,0)[b]{\lstinline{push (137)}}}} + + \put(4.55,1.05){\only<4>{\vector(1,1){0.45}}} + \put(5.00,1.60){\only<4>{\makebox(0,0)[b]{\lstinline{pop ()}: 3}}} + + \put(3.55,1.05){\only<5>{\vector(1,1){0.45}}} + \put(4.00,1.60){\only<5>{\makebox(0,0)[b]{\lstinline{pop ()}: 7}}} + + \put(2.55,1.05){\only<6>{\vector(1,1){0.45}}} + \put(3.00,1.60){\only<6>{\makebox(0,0)[b]{\lstinline{pop ()}: 137}}} + \end{picture} + + \bigskip + + FIFO = Queue = Reihe + \end{center} + \end{minipage}\hfill + \begin{minipage}[b]{6cm} + \begin{center} + "`Last In -- First Out"' + + \bigskip + + \begin{picture}(6,4) + \thicklines + \color{structure} + \put(1.5,0){\line(1,0){3}} + + \put(2.5,0){\line(0,1){1}} + \put(3.5,0){\line(0,1){1}} + \put(2.5,1){\line(1,0){1}} + \put(3.0,0.5){\makebox(0,0){\lstinline{3}}} + \put(2.0,1.5){\only<1>{\vector(1,-1){0.45}}} + \put(2.0,1.5){\only<1>{\makebox(0,0)[b]{\lstinline{push (3)}}}} + + \put(2.5,1){\only<2-5>{\line(0,1){1}}} + \put(3.5,1){\only<2-5>{\line(0,1){1}}} + \put(2.5,2){\only<2-5>{\line(1,0){1}}} + \put(3.0,1.5){\only<2-5>{\makebox(0,0){\lstinline{7}}}} + \put(2.0,2.5){\only<2>{\vector(1,-1){0.45}}} + \put(2.0,2.5){\only<2>{\makebox(0,0)[b]{\lstinline{push (7)}}}} + + \put(2.5,2){\only<3-4>{\line(0,1){1}}} + \put(3.5,2){\only<3-4>{\line(0,1){1}}} + \put(2.5,3){\only<3-4>{\line(1,0){1}}} + \put(3.0,2.5){\only<3-4>{\makebox(0,0){\lstinline{137}}}} + \put(2.0,3.5){\only<3>{\vector(1,-1){0.45}}} + \put(2.0,3.5){\only<3>{\makebox(0,0)[b]{\lstinline{push (137)}}}} + + \put(3.55,3.05){\only<4>{\vector(1,1){0.45}}} + \put(4.00,3.60){\only<4>{\makebox(0,0)[b]{\lstinline{pop ()}: 137}}} + + \put(3.55,2.05){\only<5>{\vector(1,1){0.45}}} + \put(4.00,2.60){\only<5>{\makebox(0,0)[b]{\lstinline{pop ()}: 7}}} + + \put(3.55,1.05){\only<6>{\vector(1,1){0.45}}} + \put(4.00,1.60){\only<6>{\makebox(0,0)[b]{\lstinline{pop ()}: 3}}} + \end{picture} + + \bigskip + + LIFO = Stack = Stapel + \end{center} + \end{minipage} + +% +% \dots + +\end{frame} + +\sectionnonumber{\inserttitle} + +\begin{frame} + + \showsectionnonumber + + \begin{itemize} + \item[\textbf{1}] \textbf{Einführung} + \item[\textbf{2}] \textbf{Einführung in C} + \item[\textbf{3}] \textbf{Bibliotheken} + \item[\textbf{4}] \textbf{Algorithmen} + \begin{itemize} + \item[4.1] Differentialgleichungen + \item[4.2] \color{medgreen}Rekursion + \item[4.3] Stack und FIFO + \item[4.4] \color{black}Aufwandsabschätzungen + \end{itemize} + \color{gray} + \item[\textbf{5}] \textbf{Hardwarenahe Programmierung} + \item[\makebox(0,0){\textbf{\raisebox{0.5ex}{\dots}}}] +% \item[\textbf{6}] \textbf{Ergänzungen und Ausblicke} + \end{itemize} + +\end{frame} + +\end{document} diff --git a/20151119/hex-1.c b/20151119/hex-1.c new file mode 100644 index 0000000000000000000000000000000000000000..937b43c837bd7c3f9d2b1b4652a3545014441f56 --- /dev/null +++ b/20151119/hex-1.c @@ -0,0 +1,19 @@ +#include <stdio.h> +#include <stdint.h> + +void print_hex (uint32_t x) +{ + print_hex (x / 16); + int e = x % 16; + if (e < 10) + printf ("%d", e); + else + printf ("%c", 'a' + e - 10); +} + +int main (void) +{ + print_hex (16777226); + printf ("\n"); + return 0; +} diff --git a/20151119/logo-hochschule-bochum-cvh-text.pdf b/20151119/logo-hochschule-bochum-cvh-text.pdf new file mode 120000 index 0000000000000000000000000000000000000000..a05946126bc0ce6a2818740da2893f59eb0c659c --- /dev/null +++ b/20151119/logo-hochschule-bochum-cvh-text.pdf @@ -0,0 +1 @@ +../common/logo-hochschule-bochum-cvh-text.pdf \ No newline at end of file diff --git a/20151119/logo-hochschule-bochum.pdf b/20151119/logo-hochschule-bochum.pdf new file mode 120000 index 0000000000000000000000000000000000000000..b6b9491e370e499c9276918182cdb82cb311bcd1 --- /dev/null +++ b/20151119/logo-hochschule-bochum.pdf @@ -0,0 +1 @@ +../common/logo-hochschule-bochum.pdf \ No newline at end of file diff --git a/20151119/pgscript.sty b/20151119/pgscript.sty new file mode 120000 index 0000000000000000000000000000000000000000..95c888478c99ea7fda0fd11ccf669ae91be7178b --- /dev/null +++ b/20151119/pgscript.sty @@ -0,0 +1 @@ +../common/pgscript.sty \ No newline at end of file diff --git a/20151119/pgslides.sty b/20151119/pgslides.sty new file mode 120000 index 0000000000000000000000000000000000000000..5be1416f4216f076aa268901f52a15d775e43f64 --- /dev/null +++ b/20151119/pgslides.sty @@ -0,0 +1 @@ +../common/pgslides.sty \ No newline at end of file