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

Vortragsfolien und Übungsaufgaben 6.11.2017

parent 0724861f
No related branches found
No related tags found
No related merge requests found
int fun_1 (char *s1, char *s2)
{
int result = 1;
for (int i = 0; s1[i] && s2[i]; i++)
if (s1[i] != s2[i])
result = 0;
return result;
}
File added
This diff is collapsed.
File added
% hp-uebung-20171106.pdf - Exercises on Low-Level Programming / Applied Computer Sciences
% Copyright (C) 2013, 2015, 2016 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[a4paper]{article}
\usepackage{pgscript}
\newcounter{points}
\newcommand{\onepoint}{(1 Punkt)\addtocounter{points}{1}}
\newcommand{\points}[1]{(#1 Punkte)\addtocounter{points}{#1}}
\begin{document}
\thispagestyle{empty}
\section*{Hardwarenahe Programmierung / Angewandte Informatik\\
Übungsaufgaben -- 6.\ November 2017}
\exercise{Strings}
Strings werden in der Programmiersprache C
durch Zeiger auf \lstinline{char}-Variable realisiert.
Wir betrachten die folgende Funktion (Datei: \gitfile{hp}{20171106}{aufgabe-1.c}):
\begin{center}
\begin{minipage}{8cm}
\begin{lstlisting}[gobble=8]
int fun_1 (char *s1, char *s2)
{
int result = 1;
for (int i = 0; s1[i] && s2[i]; i++)
if (s1[i] != s2[i])
result = 0;
return result;
}
\end{lstlisting}
\end{minipage}%
\end{center}
\begin{itemize}
\item[(a)]
Was bewirkt die Funktion? % \points{3}
\item[(b)]
Welchen Sinn hat die Bedingung "`\lstinline{s1[i] && s2[i]}"'
in der \lstinline{for}-Schleife? % \points{2}
\item[(c)]
Was würde sich ändern, wenn die Bedingung "`\lstinline{s1[i] && s2[i]}"'
in der \lstinline{for}-Schleife\\
zu "`\lstinline{s1[i]}"' verkürzt würde? % \points{3}
% \item[(d)]
% Von welcher Ordnung (Landau-Symbol) ist die Funktion \lstinline{fun_1()}
% hinsichtlich der Anzahl ihrer Zugriffe auf die Zeichen in den Strings
% -- und warum? % \points{2}
\item[(d)]
Schreiben Sie eine eigene Funktion,
die dieselbe Aufgabe erledigt wie \lstinline{fun_1()}, nur effizienter.
% und geben Sie die Ordnung (Landau-Symbol) der von Ihnen geschriebenen Funktion an. % \points{5}
\end{itemize}
\exercise{Text-Grafik-Bibliothek}
Schreiben Sie eine Bibliothek für "`Text-Grafik"' mit folgenden Funktionen:\vspace*{-\medskipamount}
\begin{itemize}
\item
\lstinline|void clear (char c)|\\
Bildschirm auf Zeichen \lstinline|c| löschen,\\
also komplett mit diesem Zeichen (z.\,B.: Leerzeichen) füllen
\item
\lstinline|void put_point (int x, int y, char c)|\\
Punkt setzen (z.\,B.\ einen Stern (\lstinline{*}) an die Stelle $(x,y)$ "`malen"')
\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)|\\
das Gezeichnete auf dem Bildschirm ausgeben
\end{itemize}
Hinweise:\vspace*{-\medskipamount}
\begin{itemize}
\item
Eine C-Bibliothek besteht aus (mindestens)
einer \file{.h}-Datei und einer \file{.c}-Datei.
\item
Verwenden Sie ein Array als "`Bildschirm"'.
Vor dem Aufruf der Funktion \lstinline|display()| ist nichts zu sehen;\\
alle Grafikoperationen erfolgen auf dem Array.
\item
Verwenden Sie Präprozessor-Konstante,
z.\,B.\ \lstinline{WIDTH} und \lstinline{HEIGHT},\\
um Höhe und Breite des "`Bildschirms"' festzulegen.
\item
Schreiben Sie zusätzlich ein Test-Programm,
das alle Funktionen der Bibliothek benutzt,\\
um ein hübsches Bild (z.\,B.\ ein stilisiertes Gesicht -- "`Smiley"')
auszugeben.
\end{itemize}
% \points{10}
% \points{8} % ohne "fill()"
\end{document}
../common/logo-hochschule-bochum-cvh-text.pdf
\ No newline at end of file
../common/logo-hochschule-bochum.pdf
\ No newline at end of file
../common/pgscript.sty
\ No newline at end of file
../common/pgslides.sty
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment