Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
H
hp
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Daniel
hp
Commits
c6cbb7a4
Commit
c6cbb7a4
authored
8 years ago
by
Peter Gerwinski
Browse files
Options
Downloads
Patches
Plain Diff
Klausur vom Wintersemester 2015/16
parent
a0095c0f
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
20170130/ainf-klausur-20160129.pdf
+0
-0
0 additions, 0 deletions
20170130/ainf-klausur-20160129.pdf
20170130/ainf-klausur-20160129.tex
+374
-0
374 additions, 0 deletions
20170130/ainf-klausur-20160129.tex
with
374 additions
and
0 deletions
20170130/ainf-klausur-20160129.pdf
0 → 100644
+
0
−
0
View file @
c6cbb7a4
File added
This diff is collapsed.
Click to expand it.
20170130/ainf-klausur-20160129.tex
0 → 100644
+
374
−
0
View file @
c6cbb7a4
% ainf-klausur-20160129.pdf - Examination on Applied Computer Sciences
% Copyright (C) 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
{
exercise
}
\newcommand
{
\exercise
}
[1]
{
\addtocounter
{
exercise
}{
1
}
\subsection*
{
Aufgabe
\arabic
{
exercise
}
: #1
}}
\usepackage
{
enumerate
}
\usepackage
{
ifthen
}
\newcommand
{
\workspacexyt
}
[3]
{
%
\begin{center}
\setlength
{
\unitlength
}{
0.5cm
}
\begin{picture}
(#1,#2)
\color
[rgb]
{
0.7,0.7,0.7
}
\put
(0,0)
{
\line
(1,0)
{
#1
}}
\multiput
(0,1)(0,1)
{
#2
}{
\line
(1,0)
{
#1
}}
\put
(0,0)
{
\line
(0,1)
{
#2
}}
\multiput
(1,0)(1,0)
{
#1
}{
\line
(0,1)
{
#2
}}
\put
(0,0)
{
\makebox
(#1,#2)[c]
{
\color
[rgb]
{
0.2,0.2,0.2
}
#3
}}
\end{picture}
\end{center}
}
\newcommand
{
\workspace
}
[1]
{
\workspacexyt
{
30
}{
#1
}{}}
\newcounter
{
points
}
\newcommand
{
\points
}
[1]
{
\ifthenelse
{
#1=1
}{
(1 Punkt)
}{
(#1 Punkte)
}
\addtocounter
{
points
}{
#1
}}
\begin{document}
\thispagestyle
{
empty
}
\strut\hfill
\includegraphics
[height=1.5cm]
{
logo-hochschule-bochum.pdf
}
\section*
{
Angewandte Informatik -- Klausur -- 29.
\
Januar 2016
}
Prof.~Dr.~Peter Gerwinski, Wintersemester 2015/16
\bigskip
\bigskip
\begin{center}
\renewcommand
{
\arraystretch
}{
2.0
}
\begin{tabular}
{
|l|p
{
10cm
}
|
}
\hline
Name:
&
\\\hline
Matrikel-Nr.:
&
\\\hline
\end{tabular}
\end{center}
\bigskip
Zeit: 120 Minuten
Zulässige Hilfsmittel:
\begin{itemize}
\item
Schreibgerät
\item
Beliebige Unterlagen in Papierform und/oder auf Datenträgern
\item
Elektronische Rechner (Notebook, Taschenrechner o.
\,
ä.)
\\
\emph
{
ohne
}
\/
Zugang zu Datennetzen jeglicher Art
\end{itemize}
Nur die o.
\,
a.
\
zulässigen Hilfsmittel
dürfen sich während der Klausur im Arbeitsbereich befinden.
\mbox
{
WLAN-,
}
Bluetooth- und sonstige Funkeinheiten von Notebooks o.
\,
ä.
\
sind auszuschalten;
ggf.
\
dafür vorhandene physische Schalter sind zu benutzen.
Mobiltelefone, Geräte mit mobilem Internet-Zugang u.
\,
ä.
\
sind auszuschalten und in der Tasche
zu verstauen.
Die reguläre Maximalpunktzahl beträgt
\totalpoints\
Punkte.
\\
Bei besonderen Leistungen sind Zusatzpunkte möglich.
\\
Mit 20 erreichten Punkten gilt die Klausur als bestanden.
Die Beispielprogramme werden Ihnen auf Datenträger (USB-Stick)
zur Verfügung gestellt. Die Abgabe von digital gelösten Aufgaben
hat auf demselben Datenträger zu erfolgen.
\clearpage
\exercise
{
Strings
}
Wir betrachten das folgende Programm (
\file
{
aufgabe-1.c
}
):
\begin{lstlisting}
[style=numbered]
#include <stdio.h>
#include <string.h>
void fun (char *s)
{
int len = strlen (s);
for (int i = 0; i < len; i++)
for (int j = i + 1; j < len; j++)
if (s[i] > s[j])
{
char sx = s[i];
s[i] = s[j];
s[j] = sx;
}
}
int main (void)
{
char s[] = "Informatik";
fun (s);
printf ("
%s\n", s);
return 0;
}
\end{lstlisting}
Auf einem Rechner, der den ASCII-Zeichensatz verwendet, lautet die Ausgabe:
\lstinline
[style=terminal]
{
Iafikmnort
}
\begin{enumerate}
[
\quad
(a)]
\item
Was bewirkt die Funktion
\lstinline
{
fun
}
, und wie funktioniert sie?
\points
{
4
}
\workspace
{
14
}
\item
Warum beginnt der Ausgabe-String mit
\lstinline
{
'I'
}
und nicht mit
\lstinline
{
'a'
}
?
\points
{
2
}
\workspace
{
10
}
\item
Was passiert, wenn die Zeile
\lstinline
{
char s[] = "Informatik";
}
durch
\lstinline
|char s[] =
{
'I', 'n', 'f', 'o'|~
\lstinline
|
}
;| ersetzt wird, und warum?
\points
{
2
}
\workspace
{
10
}
\item
Von welcher Ordnung (Landau-Symbol) ist die Funktion
\lstinline
{
fun
}
und warum?
Wir beziehen uns hierbei auf die Anzahl der Vergleiche
\lstinline
{
s[i] > s[j]
}
in Abhängigkeit von der Länge des Eingabe-Strings
\lstinline
{
"Informatik"
}
.
\points
{
1
}
\workspace
{
10
}
\item
Beschreiben Sie -- in Worten und/oder als C-Quelltext --, wie
sich die Funktion
\lstinline
{
fun
}
hinsichtlich der Rechenzeit
effizienter gestalten läßt. Von welcher Ordnung
(Landau-Symbol) ist Ihre effizientere Version der Funktion und warum?
\points
{
4
}
\workspace
{
21
}
\end{enumerate}
\exercise
{
Zeigerarithmetik
}
Wir betrachten das folgende Programm (
\file
{
aufgabe-2.c
}
):
\begin{lstlisting}
[style=numbered]
#include <stdio.h>
#include <stdint.h>
void output (uint16
_
t *a)
{
for (int i = 0; a[i]; i++)
printf ("
%d", a[i]);
printf ("
\n
");
}
int main (void)
{
uint16
_
t prime
_
numbers[] =
{
2, 3, 5, 7, 11, 13, 17, 0
}
;
uint16
_
t *p1 = prime
_
numbers;
output (p1);
p1++;
output (p1);
char *p2 = prime
_
numbers;
output (p2);
p2++;
output (p2);
return 0;
}
\end{lstlisting}
Das Programm wird compiliert und ausgeführt:
\begin{lstlisting}
[style=terminal]
$
¡gcc
-
Wall
-
std
=
c
99
aufgabe
-
2
.c
-
o aufgabe
-
2
¿
aufgabe
-
2
.c: In function 'main':
aufgabe
-
2
.c:
20
:
13
: warning: initialization from
incompatible pointer type
[
enabled by default
]
aufgabe
-
2
.c:
21
:
3
: warning: passing argument
1
of 'output' from
incompatible pointer type
[
enabled by default
]
aufgabe
-
2
.c:
4
:
6
: note: expected 'uint
16
_
t
*
' but argument is of type 'char
*
'
aufgabe
-
2
.c:
23
:
3
: warning: passing argument
1
of 'output' from
incompatible pointer type
[
enabled by default
]
aufgabe
-
2
.c:
4
:
6
: note: expected 'uint
16
_
t
*
' but argument is of type 'char
*
'
$
¡./aufgabe-2¿
2 3 5 7 11 13 17
3 5 7 11 13 17
2 3 5 7 11 13 17
768 1280 1792 2816 3328 4352
\end{lstlisting}
\begin{enumerate}
[
\quad
(a)]
\item
Erklären Sie die Funktionsweise der Funktion
\lstinline
{
output ()
}
.
\points
{
2
}
\workspace
{
10
}
\workspace
{
5
}
\item
Begründen Sie den Unterschied zwischen der ersten (
\lstinline
{
2 3 5 7 11 13 17
}
)
\\
und der zweiten Zeile (
\lstinline
{
3 5 7 11 13 17
}
) der Ausgabe des Programms.
\points
{
2
}
\workspace
{
11
}
\item
Erklären Sie die beim Compilieren auftretenden Warnungen
\\
und die dritte Zeile (
\lstinline
{
2 3 5 7 11 13 17
}
) der Ausgabe des Programms.
\points
{
3
}
\workspace
{
11
}
\item
Erklären Sie die vierte Zeile (
\lstinline
{
768 1280 1792 2816 3328 4352
}
)
der Ausgabe des Programms.
\\
% Welche Endianness hat der verwendete Rechner?\\
% Wie sähe die Ausgabezeile bei umgekehrter Endianness aus?
%
% 2 0 3 0 5 0 7 0 11 --> 2 3 5 7 11
% 0 3 0 5 0 7 0 11 --> 768 1280 ...
%
% 0 2 0 3 0 5 0 7 0 11 --> 2 3 5 7 11
% 2 0 3 0 5 0 7 0 11 --> 768 1280 ...
%
% --> Endianness nicht erkennbar!
%
Sie dürfen einen Little-Endian-Rechner voraussetzen.
\points
{
4
}
\workspace
{
16
}
\end{enumerate}
\exercise
{
Objektorientierte Programmierung
}
Wir betrachten das folgende Fragment (
\file
{
aufgabe-3.c
}
)
eines objektorientierten Mathematik-Programms:
\begin{lstlisting}
#include <stdio.h>
#include <stdlib.h>
typedef struct
{
char symbol;
int (*calculate) (int a, int b);
}
operation;
operation *new
_
operation (void)
{
operation *op = malloc (sizeof (operation));
op->symbol = '?';
op->calculate = NULL;
return op;
}
[...]
int main (void)
{
operation *op[4];
op[0] = new
_
plus ();
op[1] = new
_
minus ();
op[2] = new
_
times ();
op[3] = NULL;
for (int i = 0; op[i]; i++)
printf ("2
%c 3 = %d\n", op[i]->symbol, op[i]->calculate (2, 3));
return 0;
}
\end{lstlisting}
\begin{enumerate}
[
\quad
(a)]
\item
Was bedeutet
\lstinline
{
int (*calculate) (int a, int b)
}
,
und für welchen Zweck wird es verwendet?
\points
{
3
}
\workspace
{
12
}
\item
Ergänzen Sie das Fragment zu einem funktionsfähigen Programm,
das die folgende Ausgabe erzeugt:
\begin{lstlisting}
[style=terminal,gobble=8]
2 + 3 = 5
2 - 3 = -1
2 * 3 = 6
\end{lstlisting}
\points
{
5
}
Abgabe auf Datenträger ist erwünscht, aber nicht zwingend.
\\
Für Notizen verwenden Sie nötigenfalls die Rückseiten der Klausurbögen
und/oder zusätzliche Blätter.
\item
Was geschieht, wenn man auf die Zeile
\lstinline
{
op[3] = NULL;
}
verzichtet,
und warum?
\points
{
2
}
\workspace
{
8
}
\end{enumerate}
\exercise
{
XBM-Grafik
}
Bei einer XBM-Grafikdatei handelt es sich
um ein als C-Quelltext abgespeichertes Array,
das die Bildinformationen enthält:
\begin{itemize}
\itemsep
0pt
\item
Jedes Bit entspricht einem Pixel.
\item
Nullen stehen für Weiß, Einsen für Schwarz.
\item
LSB first.
\item
Jede Zeile des Bildes wird auf ganze Bytes aufgefüllt.
\item
Breite und Höhe des Bildes sind als Konstantendefinitionen
(
\lstinline
{
#define
}
) in der Datei enthalten.
\end{itemize}
Sie können eine XBM-Datei sowohl mit einem Texteditor
als auch mit vielen Grafikprogrammen öffnen und bearbeiten.
Beispiel (
\file
{
aufgabe-4.xbm
}
):
\hfill
\makebox
(0,0)[tr]
{
\framebox
{
\includegraphics
[scale=3]
{
aufgabe-4.png
}}}
\begin{lstlisting}
#define aufgabe
_
4
_
width 14
#define aufgabe
_
4
_
height 14
static unsigned char aufgabe
_
4
_
bits[] =
{
0x00, 0x00, 0xf0, 0x03, 0x08, 0x04, 0x04, 0x08, 0x02, 0x10, 0x32, 0x13,
0x22, 0x12, 0x02, 0x10, 0x0a, 0x14, 0x12, 0x12, 0xe4, 0x09, 0x08, 0x04,
0xf0, 0x03, 0x00, 0x00
}
;
\end{lstlisting}
Ein C-Programm, das eine XBM-Grafik nutzen will,
kann die
\file
{
.xbm
}
-Datei mit
\lstinline
{
#include "..."
}
direkt einbinden.
Schreiben Sie ein Programm, das die XBM-Datei als ASCII-Grafik ausgibt, z.
\,
B.:
\begin{lstlisting}
[style=terminal,lineskip=-4pt]
******
* *
* *
* *
* ** ** *
* * * *
* *
* * * *
* * * *
* **** *
* *
******
¡ ¿
\end{lstlisting}
\points
{
8
}
Abgabe auf Datenträger ist erwünscht, aber nicht zwingend.
\\
Für Notizen verwenden Sie nötigenfalls die Rückseiten der Klausurbögen
und/oder zusätzliche Blätter.
\makeatletter
\immediate\write\@
mainaux
{
\string\gdef\string\totalpoints
{
\arabic
{
points
}}}
\makeatother
\vfill
\begin{flushright}
\textit
{
Viel Erfolg!
}
\end{flushright}
\end{document}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment