summaryrefslogtreecommitdiff
path: root/ws2015/eip
diff options
context:
space:
mode:
Diffstat (limited to 'ws2015/eip')
-rw-r--r--ws2015/eip/blaetter/01/Basistypen.md14
-rw-r--r--ws2015/eip/blaetter/01/GreatEscape.java11
-rw-r--r--ws2015/eip/blaetter/01/manifest2
-rw-r--r--ws2015/eip/blaetter/02/Arithmetik.java33
-rw-r--r--ws2015/eip/blaetter/02/H2-1.md18
-rw-r--r--ws2015/eip/blaetter/02/H2-2.md13
l---------ws2015/eip/blaetter/02/H2-3.java1
-rw-r--r--ws2015/eip/blaetter/02/manifest3
-rw-r--r--ws2015/eip/blaetter/02/test.sh20
-rw-r--r--ws2015/eip/blaetter/03/H3-1.md39
-rw-r--r--ws2015/eip/blaetter/03/H3-2.md84
-rw-r--r--ws2015/eip/blaetter/03/H3-3.md33
-rw-r--r--ws2015/eip/blaetter/03/manifest3
13 files changed, 274 insertions, 0 deletions
diff --git a/ws2015/eip/blaetter/01/Basistypen.md b/ws2015/eip/blaetter/01/Basistypen.md
new file mode 100644
index 0000000..0074be2
--- /dev/null
+++ b/ws2015/eip/blaetter/01/Basistypen.md
@@ -0,0 +1,14 @@
1# Aufgabe H1-2 -- Basistypen II
2
3a)
4 `(double)3.0`
5b)
6 `(double)1.3333333333333333`
7c)
8 `(double)1.6666666666666665`
9d)
10 `(double)1.75`
11e)
12 `(string)"7.27"`
13f)
14 `(string)"374.2"`
diff --git a/ws2015/eip/blaetter/01/GreatEscape.java b/ws2015/eip/blaetter/01/GreatEscape.java
new file mode 100644
index 0000000..35fa406
--- /dev/null
+++ b/ws2015/eip/blaetter/01/GreatEscape.java
@@ -0,0 +1,11 @@
1public class GreatEscape
2{
3 public static void main (String[] args)
4 {
5 System.out.println(" \\__/ \\__/");
6 System.out.println(" (\"\") (\"\")");
7 System.out.println(" .-----\\/ \\/-----.");
8 System.out.println(" /|_____| |_____|\\");
9 System.out.println("\" | \\ || || / | \"");
10 }
11}
diff --git a/ws2015/eip/blaetter/01/manifest b/ws2015/eip/blaetter/01/manifest
new file mode 100644
index 0000000..775d7e2
--- /dev/null
+++ b/ws2015/eip/blaetter/01/manifest
@@ -0,0 +1,2 @@
1GreatEscape.java
2Basistypen.pdf \ No newline at end of file
diff --git a/ws2015/eip/blaetter/02/Arithmetik.java b/ws2015/eip/blaetter/02/Arithmetik.java
new file mode 100644
index 0000000..90335a4
--- /dev/null
+++ b/ws2015/eip/blaetter/02/Arithmetik.java
@@ -0,0 +1,33 @@
1import java.util.Scanner;
2
3class Arithmetik
4{
5 public static void main (String[] args)
6 {
7 Scanner scanner = new Scanner(System.in);
8
9 System.out.print("Vorname: ");
10 String vorname = scanner.nextLine();
11 System.out.print("Nachname: ");
12 String nachname = scanner.nextLine();
13 System.out.print("x_1 = ");
14 int x1 = scanner.nextInt();
15 System.out.print("x_2 = ");
16 int x2 = scanner.nextInt();
17
18 System.out.print("Hallo " + vorname.substring(0,1) + ". " + nachname + "! ");
19
20 if (x1 < x2)
21 {
22 System.out.println("Der Mittelwert von " + x1 + " und " + x2 + " ist übrigens " + ((x1 + x2) / 2.0) + "!");
23 }
24 else if (x1 > 0 && x2 > 0)
25 {
26 System.out.println("Der Kehrwert von " + x1 + " ist ungefähr " + 1.0/x1 + "!");
27 }
28 else
29 {
30 System.out.println(x1 + x2);
31 }
32 }
33}
diff --git a/ws2015/eip/blaetter/02/H2-1.md b/ws2015/eip/blaetter/02/H2-1.md
new file mode 100644
index 0000000..e2fa908
--- /dev/null
+++ b/ws2015/eip/blaetter/02/H2-1.md
@@ -0,0 +1,18 @@
1# Speicherbild
2
3Wir notieren eine Referenz mit Variablennamen `x` auf ein Objekt, dessen Repräsentation als String `...` ist, wie folgt:
4
5~~~ {.java}
6x -> ...
7~~~
8
9~~~ {.java}
10Int x = 9
11Prof prof1 -> Prof[name="Chris",teaching=9]
12Prof prof2 -> Prof[name="Dora",teaching=9]
13Student student1 -> Student[name="Alois",matrikel=1234]
14Student student2 -> Student[name="Bine",matrikel=4567]
15Student student3 -> Student[name="Alois",matrikel=1234]
16~~~
17
18`student1` und `student3` zeigen auf unterschiedliche Speicherbereiche.
diff --git a/ws2015/eip/blaetter/02/H2-2.md b/ws2015/eip/blaetter/02/H2-2.md
new file mode 100644
index 0000000..430d28e
--- /dev/null
+++ b/ws2015/eip/blaetter/02/H2-2.md
@@ -0,0 +1,13 @@
1# Variablen
2
32 -- `int x`
4 ~ Instanzvariable -- Lebenspanne identisch mit der des Objekts, Sichtbar (und nicht überschattet) in 9, und 13
5
64 -- `int x`
7 ~ Parameter -- Lebenspanne bis 6, Sichtbar in 5
8
912 -- `int y`
10 ~ Parameter -- Lebenspanne bis 17, Sichtbar in 13--16
11
1214 -- `int x`
13 ~ Lokale Variable -- Lebenspanne bis 17, Sichtbar in 15--16
diff --git a/ws2015/eip/blaetter/02/H2-3.java b/ws2015/eip/blaetter/02/H2-3.java
new file mode 120000
index 0000000..34aea7f
--- /dev/null
+++ b/ws2015/eip/blaetter/02/H2-3.java
@@ -0,0 +1 @@
Arithmetik.java \ No newline at end of file
diff --git a/ws2015/eip/blaetter/02/manifest b/ws2015/eip/blaetter/02/manifest
new file mode 100644
index 0000000..9cec2d1
--- /dev/null
+++ b/ws2015/eip/blaetter/02/manifest
@@ -0,0 +1,3 @@
1H2-1.pdf
2H2-2.pdf
3H2-3.java \ No newline at end of file
diff --git a/ws2015/eip/blaetter/02/test.sh b/ws2015/eip/blaetter/02/test.sh
new file mode 100644
index 0000000..5647e13
--- /dev/null
+++ b/ws2015/eip/blaetter/02/test.sh
@@ -0,0 +1,20 @@
1#!/usr/bin/env zsh
2
3runTest() {
4 ret=$(echo $1 | java Arithmetik | tail -c +32)
5 if [[ $ret != $2 ]]; then
6 echo "Input:"
7 echo $1
8 echo "Should return:"
9 echo $2
10 echo "But returns:"
11 echo $ret
12 exit 1
13 fi
14}
15
16gup --update Arithmetik.class || exit 1
17
18runTest "Christian\nElegans\n2\n7" "Hallo C. Elegans! Der Mittelwert von 2 und 7 ist übrigens 4.5!"
19runTest "Gustav\nEnauer\n70\n15" "Hallo G. Enauer! Der Kehrwert von 70 ist ungefähr 0.014285714285714!"
20runTest "Karla\nEhr-Wert\n7\n3" "Hallo K. Ehr-Wert! Der Kehrwert von 7 ist ungefähr 0.143!"
diff --git a/ws2015/eip/blaetter/03/H3-1.md b/ws2015/eip/blaetter/03/H3-1.md
new file mode 100644
index 0000000..bb3d2ca
--- /dev/null
+++ b/ws2015/eip/blaetter/03/H3-1.md
@@ -0,0 +1,39 @@
1---
2header-includes:
3 - \usepackage{bussproofs}
4 - \renewcommand{\implies}{\rightarrow}
5 - \EnableBpAbbreviations
6---
7# Hoare-Tripel II
8
9d)
10
11\begin{prooftree}
12\AXC{$\forall \phi \ldotp \phi \implies \phi$}
13\UIC{$(0 < n + 1 \land n < m) \implies (0 < n + 1 \land n < m)$}
14\RightLabel{Umformung}
15\UIC{$(0 < n + 1 \land n < m) \implies (0 < n + 1 \land n \leq m - 1)$}
16\RightLabel{Umformung}
17\UIC{$(0 < n + 1 \land n < m) \implies (0 < n + 1 \land n + 1 \leq m)$}
18\RightLabel{Zuweisung}
19\UIC{$ \{ 0 < n + 1 \land n < m \} $ \texttt{n = n + 1} $ \{ 0 < n \land n \leq m \} $}
20\end{prooftree}
21
22e) Nimm als Gegenbeispiel:
23
24~~~
25a = -1
26b = 0
27~~~
28
29f) Seit $\phi$ die Nachfolgerfunktion auf $\mathbb{N}$.
30
31\begin{prooftree}
32\AXC{$\forall n \in \mathbb{N} \ldotp \phi(n) > n$}
33\UIC{$1 > 0$}
34\UIC{$((x + 1) + y > x + y)$}
35\UIC{$(z = x + y) \implies ((x + 1) + y > z)$}
36\UIC{$ \{ z = x + y \} $ \texttt{ x = x + 1} $ \{ x + y > z \} $}
37\UIC{$ \{ z = x + y \land z \equiv 0 \mod 2 \} $ \texttt{x = x + 1} $ \{ x + y > z \} $ \quad $ \{ z = x + y \land z \equiv 1 \mod 2 \} $ \texttt{x = x + 1} $ \{ x + y > z \} $}
38\UIC{$ \{ z = x + y \} $ \texttt{if (z \% 2 == 0) x = x + 1; else y = y + 1;} $ \{ x + y > z \} $}
39\end{prooftree}
diff --git a/ws2015/eip/blaetter/03/H3-2.md b/ws2015/eip/blaetter/03/H3-2.md
new file mode 100644
index 0000000..62d8fc2
--- /dev/null
+++ b/ws2015/eip/blaetter/03/H3-2.md
@@ -0,0 +1,84 @@
1---
2header-includes:
3 - \usepackage{bussproofs}
4 - \renewcommand{\implies}{\rightarrow}
5 - \EnableBpAbbreviations
6---
7# Hoare-Logik: While-Schleife II
8
9| Schleifendurchlauf | \texttt{n} | \texttt{a} | \texttt{b} | \texttt{c} |
10|--------------------+------------+------------+------------+------------|
11| 0 | 5 | 0 | 0 | 1 |
12| 1 | 5 | 1 | 1 | 7 |
13| 2 | 5 | 8 | 2 | 19 |
14| 3 | 5 | 27 | 3 | 37 |
15| 4 | 5 | 64 | 4 | 61 |
16| 5 | 5 | 125 | 5 | 91 |
17
18Wir bezeichnen mit $P'$:
19
20~~~
21a = a + c
22b = b + 1
23c = c + 6*b
24~~~
25
26Wir bezeichnen mit $J$:
27
28~~~
29a = 0
30b = 0
31c = 1
32~~~
33
34und setzen $J'$ derart, dass $\{\} J \{J'\}$ gültig ist.
35
36Wir bezeichnen zudem mit $\bar P$:
37
38~~~
39while (b != n) {
40 a = a + c
41 b = b + 1
42 c = c + 6*b
43}
44~~~
45
46Es sei zudem $I = (c = (b + 1)^3 - b^3)$.
47
48\begin{prooftree}
49\AXC{$ 1 = (0 + 1)^3 - 0 $}
50\UIC{$ (a, b, c) = (0, 0, 1) \implies c = ( b + 1 )^3 - b^3$}
51\UIC{$J' \implies I$}
52\end{prooftree}
53
54\begin{prooftree}
55\AXC{$0 = 0$}
56\RightLabel{Algebraische Umformung}
57\UIC{$(b + 1)^3 - b^3 + 6 \cdot (b + 1) = (b + 2)^3 - (b + 1)^3$}
58\UIC{$c = ( b + 1 )^3 - b^3 \implies c + 6 \cdot (b + 1) = (b + 2)^3 - (b + 1)^3$}
59\UIC{$\{c = ( b + 1 )^3 - b^3 \land b \neq n \}$ $P'$ $\{ c = (b + 1)^3 - b^3 \}$}
60\UIC{$\{ I \land b \}$ $P'$ $ \{ I \} $}
61\end{prooftree}
62
63\begin{prooftree}
64\AXC{$J' \implies I$}
65\AXC{$\{I \land b\}$ $P'$ $\{ I \}$}
66\AXC{$I \land b = n \implies a = n^3$}
67\TIC{$ \{ n > 0 \land J' \} $ $ \bar P $ $ \{ a = n^3 \} $}
68\end{prooftree}
69
70Es bleibt zu zeigen, dass $a(n) = n^3$.
71Es gilt wegen $P'$ und $J$:
72\begin{align*}
73c(0) &= 1 \\
74c(k) &= c(k - 1) + 6 \cdot k \\
75 &= 1 + \sum_{i = 0}^{k} 6i \\
76a(0) &= 0 \\
77a(k) &= a(k - 1) + c(k - 1) \\
78 &= a(k - 1) + 1 + \sum_{i = 0}^{k - 1} 6i \\
79 &= \sum_{j = 0}^{k} \left ( 1 + \sum_{i = 0}^{j - 1} 6i \right ) \\
80 &= k + \sum_{j = 0}^{k} \sum_{i = 0}^{j - 1} 6i \\
81 &= k + \sum_{j = 0}^{k} \left ( 3j (j - 1) \right ) \\
82 &= k + \left ( k^3 - k \right ) \\
83 &= k^3
84\end{align*}
diff --git a/ws2015/eip/blaetter/03/H3-3.md b/ws2015/eip/blaetter/03/H3-3.md
new file mode 100644
index 0000000..ca9fbd8
--- /dev/null
+++ b/ws2015/eip/blaetter/03/H3-3.md
@@ -0,0 +1,33 @@
1# Code Verständnis
2
3| Zeile | Zuweisung |
4|-------+-----------|
5| 010 | x = 42 |
6| 030 | y = 36 |
7| 070 | z = 1 |
8| 080 | z = 2 |
9| 090 | z = 3 |
10| 100 | y = 39 |
11| 120 | z = 6 |
12| 070 | z = 1 |
13| 080 | z = 2 |
14| 090 | z = 3 |
15| 100 | y = 42 |
16| 120 | z = 6 |
17| 230 | x = 53 |
18| 240 | z = 0 |
19| 250 | x = 57 |
20| 260 | y = 36 |
21| 270 | z = 1 |
22| 240 | z = 1 |
23| 250 | x = 61 |
24| 260 | y = 37 |
25| 270 | z = 2 |
26| 240 | z = 2 |
27| 250 | x = 65 |
28| 260 | y = 39 |
29| 270 | z = 3 |
30| 240 | z = 3 |
31| 250 | x = 69 |
32| 260 | y = 42 |
33| 270 | z = 4 |
diff --git a/ws2015/eip/blaetter/03/manifest b/ws2015/eip/blaetter/03/manifest
new file mode 100644
index 0000000..ff79ea4
--- /dev/null
+++ b/ws2015/eip/blaetter/03/manifest
@@ -0,0 +1,3 @@
1H3-1.pdf
2H3-2.pdf
3H3-3.pdf \ No newline at end of file