Skip to content
Snippets Groups Projects
Commit d28888d2 authored by Peter Gerwinski's avatar Peter Gerwinski
Browse files

kleinere Korrekturen 8.10.2018

parent 3e2222ac
Branches
No related tags found
No related merge requests found
Showing
with 216 additions and 29 deletions
No preview for this file type
...@@ -47,7 +47,7 @@ ...@@ -47,7 +47,7 @@
\date{\begin{picture}(0,0) \date{\begin{picture}(0,0)
\color{red} \color{red}
\put(0.65,1.05){\makebox(0,0)[t]{$\underbrace{\rule{1.45cm}{0pt}}_{% \put(0.55,1.05){\makebox(0,0)[t]{$\underbrace{\rule{1.45cm}{0pt}}_{%
\mbox{\emph{rerum naturalium\/} = der natürlichen Dinge (lat.)}}$}} \mbox{\emph{rerum naturalium\/} = der natürlichen Dinge (lat.)}}$}}
\end{picture}% \end{picture}%
8.\ Oktober 2018} 8.\ Oktober 2018}
...@@ -364,7 +364,7 @@ ...@@ -364,7 +364,7 @@
\showsubsection \showsubsection
\begin{onlyenv}<1-4> \begin{onlyenv}<1-5>
\begin{lstlisting}[style=terminal,gobble=6] \begin{lstlisting}[style=terminal,gobble=6]
$ ¡gcc hello-1.c -o hello-1¿ $ ¡gcc hello-1.c -o hello-1¿
$ ¡./hello-1¿ $ ¡./hello-1¿
...@@ -372,7 +372,7 @@ ...@@ -372,7 +372,7 @@
$ $
\end{lstlisting} \end{lstlisting}
\end{onlyenv} \end{onlyenv}
\begin{onlyenv}<5-> \begin{onlyenv}<6->
\begin{lstlisting}[style=terminal,gobble=6] \begin{lstlisting}[style=terminal,gobble=6]
$ ¡gcc -Wall -O hello-1.c -o hello-1¿ $ ¡gcc -Wall -O hello-1.c -o hello-1¿
$ ¡./hello-1¿ $ ¡./hello-1¿
...@@ -380,7 +380,7 @@ ...@@ -380,7 +380,7 @@
$ $
\end{lstlisting} \end{lstlisting}
\end{onlyenv} \end{onlyenv}
\begin{onlyenv}<2> \begin{onlyenv}<3>
\bigskip \bigskip
Hier: Kommandozeilen-Interface (CLI) Hier: Kommandozeilen-Interface (CLI)
\begin{itemize} \begin{itemize}
...@@ -393,7 +393,9 @@ ...@@ -393,7 +393,9 @@
\item \item
aktuelles Verzeichnis ausgeben: \lstinline[style=cmd]{pwd} aktuelles Verzeichnis ausgeben: \lstinline[style=cmd]{pwd}
\item \item
Inhalt des aktuellen Verzeichnisses ausgeben: \lstinline[style=cmd]{ls} aktuelles Verzeichnis wechseln: \lstinline[style=cmd]{cd foobar}, \lstinline[style=cmd]{cd ..}
\item
Inhalt des aktuellen Verzeichnisses ausgeben: \lstinline[style=cmd]{ls}, \lstinline[style=cmd]{ls -l}
\item \item
Ausführen des Programms (\file{hello-1}) im aktuellen Verzeichnis (\file{.}):\\ Ausführen des Programms (\file{hello-1}) im aktuellen Verzeichnis (\file{.}):\\
\lstinline[style=cmd]{./hello-1} \lstinline[style=cmd]{./hello-1}
...@@ -406,12 +408,12 @@ ...@@ -406,12 +408,12 @@
Das können Sie bereits. Das können Sie bereits.
\end{itemize} \end{itemize}
\end{onlyenv} \end{onlyenv}
\begin{onlyenv}<3> \begin{onlyenv}<4>
\bigskip \bigskip
GNU Compiler Collection (GCC) für verschiedene Plattformen: GNU Compiler Collection (GCC) für verschiedene Plattformen:
\begin{itemize} \begin{itemize}
\item \item
GNU/Linux: in der Distribution enthalten GNU/Linux: \file{gcc}
\item \item
Apple Mac OS: \file{Xcode} Apple Mac OS: \file{Xcode}
\item \item
...@@ -421,10 +423,25 @@ ...@@ -421,10 +423,25 @@
\item \item
außerdem: Texteditor\\ außerdem: Texteditor\\
\file{vi}(\file{m}), \file{nano}, \file{vi}(\file{m}), \file{nano},
\file{Emacs}, \file{Notepad++}, \dots \file{Emacs}, \file{Notepad++}, \dots\\
(Microsoft Notepad ist \emph{nicht} geeignet!)
\end{itemize} \end{itemize}
\end{onlyenv} \end{onlyenv}
\begin{onlyenv}<5-> \begin{onlyenv}<2>
\begin{picture}(0,0)
\color{red}
\put(4.0,0.5){\tikz{\draw[-latex](0.0,0.0)--(-2.0,1.0);}}
\put(4.0,0.3){\makebox(0,0)[tl]{\begin{minipage}[t]{8cm}
\begin{tabular}{ll}
\lstinline[style=cmd]{-o hello-1}
& Name für Ausgabe-Datei ("`output"') \\
& unter Unix: ohne Endung \\
& unter MS-Windows: Endung \lstinline[style=cmd]{.exe}
\end{tabular}
\end{minipage}}}
\end{picture}
\end{onlyenv}
\begin{onlyenv}<6->
\begin{picture}(0,0) \begin{picture}(0,0)
\color{red} \color{red}
\put(3.0,0.5){\tikz{\draw[-latex](0.0,0.0)--(-3.0,1.0);}} \put(3.0,0.5){\tikz{\draw[-latex](0.0,0.0)--(-3.0,1.0);}}
...@@ -525,7 +542,8 @@ ...@@ -525,7 +542,8 @@
\put(3.4,1.8){\tikz{\draw[-latex](0.0,0.0)--(-3.5,0);}} \put(3.4,1.8){\tikz{\draw[-latex](0.0,0.0)--(-3.5,0);}}
\put(7.0,1.9){\begin{minipage}[t]{5cm} \put(7.0,1.9){\begin{minipage}[t]{5cm}
Formatspezifikation "`lf"':\\ Formatspezifikation "`lf"':\\
"`long floating-point"' "`long floating-point"'\\[\smallskipamount]
Das "`\&"' nicht vergessen!
\end{minipage}} \end{minipage}}
\end{picture} \end{picture}
...@@ -576,7 +594,7 @@ ...@@ -576,7 +594,7 @@
\smallskip \smallskip
Die beiden Gleichzeitszeicen haben\\ Die beiden Gleichzeitszeichen haben\\
\emph{subtil unterschiedliche\/} Bedeutungen! \emph{subtil unterschiedliche\/} Bedeutungen!
\end{frame} \end{frame}
......
No preview for this file type
% hp-musterloesung-20171009.pdf - Solutions to the Exercises on Low-Level Programming / Applied Computer Sciences % hp-musterloesung-20181008.pdf - Solutions to the Exercises on Low-Level Programming / Applied Computer Sciences
% Copyright (C) 2013, 2015, 2016, 2017 Peter Gerwinski % Copyright (C) 2013, 2015, 2016, 2017, 2018 Peter Gerwinski
% %
% This document is free software: you can redistribute it and/or % This document is free software: you can redistribute it and/or
% modify it either under the terms of the Creative Commons % modify it either under the terms of the Creative Commons
...@@ -28,8 +28,8 @@ ...@@ -28,8 +28,8 @@
\thispagestyle{empty} \thispagestyle{empty}
\section*{Hardwarenahe Programmierung / Angewandte Informatik\\ \section*{Hardwarenahe Programmierung\\
Musterlösung zu den Übungsaufgaben -- 9.\ Oktober 2017} Musterlösung zu den Übungsaufgaben -- 8.\ Oktober 2018}
\addtocounter{exercise}{1} \addtocounter{exercise}{1}
...@@ -50,15 +50,15 @@ ...@@ -50,15 +50,15 @@
\solution \solution
Drei verschiedene richtige Lösungen finden Sie in den Dateien Drei verschiedene richtige Lösungen finden Sie in den Dateien
\gitfile{hp}{20171009}{loesung-2-1.c}, \gitfile{hp}{20171009}{loesung-2-2.c} und \gitfile{hp}{20171009}{loesung-2-3.c}. \gitfile{hp}{20181008}{loesung-2-1.c}, \gitfile{hp}{20181008}{loesung-2-2.c} und \gitfile{hp}{20181008}{loesung-2-3.c}.
(Zum Compilieren von \gitfile{hp}{20171009}{loesung-2-2.c} und \gitfile{hp}{20171009}{loesung-2-3.c} (Zum Compilieren von \gitfile{hp}{20181008}{loesung-2-2.c} und \gitfile{hp}{20181008}{loesung-2-3.c}
ist mindestens der C99-Standard erforderlich; bitte nötigenfalls ist mindestens der C99-Standard erforderlich; bitte nötigenfalls
in \file{gcc} die Option \lstinline[style=cmd]{-std=c99} mit angeben.) in \file{gcc} die Option \lstinline[style=cmd]{-std=c99} mit angeben.)
Die Lösung in \gitfile{hp}{20171009}{loesung-2-3.c} ist zwar richtig, Die Lösung in \gitfile{hp}{20181008}{loesung-2-3.c} ist zwar richtig,
aber unnötig kompliziert und daher nicht empfohlen. aber unnötig kompliziert und daher nicht empfohlen.
Eine \textbf{falsche} Lösung finden Sie in der Datei \gitfile{hp}{20171009}{loesung-2-f4.c}: Eine \textbf{falsche} Lösung finden Sie in der Datei \gitfile{hp}{20181008}{loesung-2-f4.c}:
In der Ausgabe dieses Programms stehen die Faktoren und Ergebnisse In der Ausgabe dieses Programms stehen die Faktoren und Ergebnisse
nicht rechtsbündig untereinander. nicht rechtsbündig untereinander.
...@@ -163,25 +163,25 @@ ...@@ -163,25 +163,25 @@
return 0; return 0;
} }
\end{lstlisting} \end{lstlisting}
In den Dateien \gitfile{hp}{20171009}{loesung-3-1.c} bis \gitfile{hp}{20171009}{loesung-3-3.c} In den Dateien \gitfile{hp}{20181008}{loesung-3-1.c} bis \gitfile{hp}{20181008}{loesung-3-3.c}
finden Sie lauffähige Programme, die die o.\,a.\ Funktionen aufrufen. finden Sie lauffähige Programme, die die o.\,a.\ Funktionen aufrufen.
Beachten Sie, daß die Funktion \emph{vor\/} dem Hauptprogramm Beachten Sie, daß die Funktion \emph{vor\/} dem Hauptprogramm
deklariert werden muß, damit das Hauptprogramm sie kennt. deklariert werden muß, damit das Hauptprogramm sie kennt.
(Es gibt Tricks, mit denen es auch anders geht, (Es gibt Tricks, mit denen es auch anders geht,
aber was hätten wir in diesem Zusammenhang davon?) aber was hätten wir in diesem Zusammenhang davon?)
In \gitfile{hp}{20171009}{loesung-3-4.c} und \gitfile{hp}{20171009}{loesung-3-5.c} In \gitfile{hp}{20181008}{loesung-3-4.c} und \gitfile{hp}{20181008}{loesung-3-5.c}
findet die Schaltjahr-Prüfung direkt im Hauptprogramm statt. findet die Schaltjahr-Prüfung direkt im Hauptprogramm statt.
Dies ist ebenfalls eine richtige Lösung der Aufgabe, Dies ist ebenfalls eine richtige Lösung der Aufgabe,
schränkt aber die Wiederverwertbarkeit des Codes ein. schränkt aber die Wiederverwertbarkeit des Codes ein.
Die Datei \gitfile{hp}{20171009}{loesung-3-4.c} enthält darüberhinaus Codeverdopplungen, Die Datei \gitfile{hp}{20181008}{loesung-3-4.c} enthält darüberhinaus Codeverdopplungen,
nämlich mehrere identische \lstinline{printf()}-Auf"-rufe nämlich mehrere identische \lstinline{printf()}-Auf"-rufe
an unterschiedlichen Stellen. an unterschiedlichen Stellen.
Dies ist schlechter Programmierstil ("`Cut-and-paste-Programmierung"'). Dies ist schlechter Programmierstil ("`Cut-and-paste-Programmierung"').
Die besten Lösungen sind \gitfile{hp}{20171009}{loesung-3-2.c} Die besten Lösungen sind \gitfile{hp}{20181008}{loesung-3-2.c}
und \gitfile{hp}{20171009}{loesung-3-3.c}. und \gitfile{hp}{20181008}{loesung-3-3.c}.
\goodbreak \goodbreak
...@@ -195,17 +195,17 @@ ...@@ -195,17 +195,17 @@
\item 2000 ist ein Schaltjahr. \item 2000 ist ein Schaltjahr.
\item 2002 ist kein Schaltjahr. \item 2002 ist kein Schaltjahr.
\item 2004 ist ein Schaltjahr. \item 2004 ist ein Schaltjahr.
\item 2014 ist kein Schaltjahr.
\item 2015 ist kein Schaltjahr. \item 2015 ist kein Schaltjahr.
\item 2016 ist ein Schaltjahr. \item 2016 ist ein Schaltjahr.
\item 2017 ist kein Schaltjahr. \item 2017 ist kein Schaltjahr.
\item 2018 ist kein Schaltjahr.
\end{itemize} \end{itemize}
Hier noch ein Hinweis für Unix-Shell-Experten: Hier noch ein Hinweis für Unix-Shell-Experten:
\begin{lstlisting}[style=cmd] \begin{lstlisting}[style=cmd]
for y in 1 2 3 4 5; do for y in 1 2 3 4 5; do
clear clear
for x in 1900 1902 1904 1996 1998 2000 2002 2004 2014 2015 2016 2017; do for x in 1900 1902 1904 1996 1998 2000 2002 2004 2015 2016 2017 2018; do
echo $x | ./loesung-3-$y echo $x | ./loesung-3-$y
done done
sleep 2s sleep 2s
......
No preview for this file type
...@@ -32,7 +32,7 @@ ...@@ -32,7 +32,7 @@
\thispagestyle{empty} \thispagestyle{empty}
\section*{Hardwarenahe Programmierung / Angewandte Informatik\\ \section*{Hardwarenahe Programmierung\\
Übungsaufgaben -- 8.\ Oktober 2018} Übungsaufgaben -- 8.\ Oktober 2018}
\exercise{Hello, world!} \exercise{Hello, world!}
......
#include <stdio.h>
int main (void)
{
int a = 1;
int b = 7;
while (a <= 10)
{
printf ("%2d * %d = %2d\n", a, b, a * b);
a++;
}
return 0;
}
#include <stdio.h>
int main (void)
{
int x = 7;
for (int i = 1; i <= 10; i++)
printf ("%2d *%2d =%3d\n", i, x, i * x);
return 0;
}
#include <stdio.h>
int main (void)
{
int x = 7;
for (int i = 1; i <= 10; i++)
{
if (i >= 10)
printf ("%d", i);
else
printf (" %d", i);
printf (" * %d = ", x);
int y = i * x;
if (y >= 10)
printf ("%d", y);
else
printf (" %d", y);
printf ("\n");
}
return 0;
}
#include <stdio.h>
int main (void)
{
int x = 7;
for (int i = 1; i <= 10; i++)
printf ("%d * %d = %d\n", i, x, i * x);
return 0;
}
#include <stdio.h>
int is_leap_year (int year)
{
int leap_year = 0;
if (year % 4 == 0)
{
leap_year = 1;
if (year % 100 == 0)
{
leap_year = 0;
if (year % 400 == 0)
leap_year = 1;
}
}
return leap_year;
}
int main (void)
{
int year;
printf ("Bitte geben Sie eine Jahreszahl ein: ");
scanf ("%d", &year);
if (is_leap_year (year))
printf ("Das Jahr %d ist ein Schaltjahr.\n", year);
else
printf ("Das Jahr %d ist kein Schaltjahr.\n", year);
return 0;
}
#include <stdio.h>
int is_leap_year (int year)
{
if (year % 4 == 0)
{
if (year % 100 == 0)
{
if (year % 400 == 0)
return 1;
else
return 0;
}
else
return 1;
}
else
return 0;
}
int main (void)
{
int year;
printf ("Bitte geben Sie eine Jahreszahl ein: ");
scanf ("%d", &year);
if (is_leap_year (year))
printf ("Das Jahr %d ist ein Schaltjahr.\n", year);
else
printf ("Das Jahr %d ist kein Schaltjahr.\n", year);
return 0;
}
#include <stdio.h>
int is_leap_year (int year)
{
if (year % 4 == 0 && (year % 100 != 0 || year % 400 == 0))
return 1;
else
return 0;
}
int main (void)
{
int year;
printf ("Bitte geben Sie eine Jahreszahl ein: ");
scanf ("%d", &year);
if (is_leap_year (year))
printf ("Das Jahr %d ist ein Schaltjahr.\n", year);
else
printf ("Das Jahr %d ist kein Schaltjahr.\n", year);
return 0;
}
#include <stdio.h>
int main (void)
{
int year;
printf ("Bitte geben Sie eine Jahreszahl ein: ");
scanf ("%d", &year);
if (year % 4 == 0)
{
if (year % 100 == 0)
{
if (year % 400 == 0)
printf ("Das Jahr %d ist ein Schaltjahr.\n", year);
else
printf ("Das Jahr %d ist kein Schaltjahr.\n", year);
}
else
printf ("Das Jahr %d ist ein Schaltjahr.\n", year);
}
else
printf ("Das Jahr %d ist kein Schaltjahr.\n", year);
return 0;
}
#include <stdio.h>
int main (void)
{
int year;
printf ("Bitte geben Sie eine Jahreszahl ein: ");
scanf ("%d", &year);
if (year % 4 == 0 && (year % 100 != 0 || year % 400 == 0))
printf ("Das Jahr %d ist ein Schaltjahr.\n", year);
else
printf ("Das Jahr %d ist kein Schaltjahr.\n", year);
return 0;
}
../common/logo-hochschule-bochum-cvh-text-v2.pdf
\ No newline at end of file
../common/logo-hochschule-bochum-cvh-text.pdf
\ No newline at end of file
File added
File deleted
...@@ -74,7 +74,7 @@ ...@@ -74,7 +74,7 @@
\minimalistictrue \minimalistictrue
\institute[Hochschule Bochum\sep CVH]{% \institute[Hochschule Bochum\sep CVH]{%
\makebox(0,0)[tl]{\includegraphics[scale=0.57]{logo-hochschule-bochum-cvh-text.pdf}}\hfill \makebox(0,0.005)[tl]{\includegraphics[scale=0.72]{logo-hochschule-bochum-cvh-text-v2.pdf}}\hfill
\makebox(0,0)[tr]{\includegraphics[scale=0.5]{logo-hochschule-bochum.pdf}}% \makebox(0,0)[tr]{\includegraphics[scale=0.5]{logo-hochschule-bochum.pdf}}%
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment