diff options
Diffstat (limited to 'ws2015/EiP/blaetter')
-rw-r--r-- | ws2015/EiP/blaetter/01/Basistypen.md | 14 | ||||
-rw-r--r-- | ws2015/EiP/blaetter/01/GreatEscape.java | 11 | ||||
-rw-r--r-- | ws2015/EiP/blaetter/01/manifest | 2 | ||||
-rw-r--r-- | ws2015/EiP/blaetter/02/Arithmetik.java | 33 | ||||
-rw-r--r-- | ws2015/EiP/blaetter/02/H2-1.md | 18 | ||||
-rw-r--r-- | ws2015/EiP/blaetter/02/H2-2.md | 13 | ||||
l--------- | ws2015/EiP/blaetter/02/H2-3.java | 1 | ||||
-rw-r--r-- | ws2015/EiP/blaetter/02/manifest | 3 | ||||
-rw-r--r-- | ws2015/EiP/blaetter/02/test.sh | 20 | ||||
-rw-r--r-- | ws2015/EiP/blaetter/03/H3-1.md | 39 | ||||
-rw-r--r-- | ws2015/EiP/blaetter/03/H3-2.md | 84 | ||||
-rw-r--r-- | ws2015/EiP/blaetter/03/H3-3.md | 33 | ||||
-rw-r--r-- | ws2015/EiP/blaetter/03/manifest | 3 |
13 files changed, 0 insertions, 274 deletions
diff --git a/ws2015/EiP/blaetter/01/Basistypen.md b/ws2015/EiP/blaetter/01/Basistypen.md deleted file mode 100644 index 0074be2..0000000 --- a/ws2015/EiP/blaetter/01/Basistypen.md +++ /dev/null | |||
@@ -1,14 +0,0 @@ | |||
1 | # Aufgabe H1-2 -- Basistypen II | ||
2 | |||
3 | a) | ||
4 | `(double)3.0` | ||
5 | b) | ||
6 | `(double)1.3333333333333333` | ||
7 | c) | ||
8 | `(double)1.6666666666666665` | ||
9 | d) | ||
10 | `(double)1.75` | ||
11 | e) | ||
12 | `(string)"7.27"` | ||
13 | f) | ||
14 | `(string)"374.2"` | ||
diff --git a/ws2015/EiP/blaetter/01/GreatEscape.java b/ws2015/EiP/blaetter/01/GreatEscape.java deleted file mode 100644 index 35fa406..0000000 --- a/ws2015/EiP/blaetter/01/GreatEscape.java +++ /dev/null | |||
@@ -1,11 +0,0 @@ | |||
1 | public 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 deleted file mode 100644 index 775d7e2..0000000 --- a/ws2015/EiP/blaetter/01/manifest +++ /dev/null | |||
@@ -1,2 +0,0 @@ | |||
1 | GreatEscape.java | ||
2 | Basistypen.pdf \ No newline at end of file | ||
diff --git a/ws2015/EiP/blaetter/02/Arithmetik.java b/ws2015/EiP/blaetter/02/Arithmetik.java deleted file mode 100644 index 90335a4..0000000 --- a/ws2015/EiP/blaetter/02/Arithmetik.java +++ /dev/null | |||
@@ -1,33 +0,0 @@ | |||
1 | import java.util.Scanner; | ||
2 | |||
3 | class 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 deleted file mode 100644 index e2fa908..0000000 --- a/ws2015/EiP/blaetter/02/H2-1.md +++ /dev/null | |||
@@ -1,18 +0,0 @@ | |||
1 | # Speicherbild | ||
2 | |||
3 | Wir notieren eine Referenz mit Variablennamen `x` auf ein Objekt, dessen Repräsentation als String `...` ist, wie folgt: | ||
4 | |||
5 | ~~~ {.java} | ||
6 | x -> ... | ||
7 | ~~~ | ||
8 | |||
9 | ~~~ {.java} | ||
10 | Int x = 9 | ||
11 | Prof prof1 -> Prof[name="Chris",teaching=9] | ||
12 | Prof prof2 -> Prof[name="Dora",teaching=9] | ||
13 | Student student1 -> Student[name="Alois",matrikel=1234] | ||
14 | Student student2 -> Student[name="Bine",matrikel=4567] | ||
15 | Student 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 deleted file mode 100644 index 430d28e..0000000 --- a/ws2015/EiP/blaetter/02/H2-2.md +++ /dev/null | |||
@@ -1,13 +0,0 @@ | |||
1 | # Variablen | ||
2 | |||
3 | 2 -- `int x` | ||
4 | ~ Instanzvariable -- Lebenspanne identisch mit der des Objekts, Sichtbar (und nicht überschattet) in 9, und 13 | ||
5 | |||
6 | 4 -- `int x` | ||
7 | ~ Parameter -- Lebenspanne bis 6, Sichtbar in 5 | ||
8 | |||
9 | 12 -- `int y` | ||
10 | ~ Parameter -- Lebenspanne bis 17, Sichtbar in 13--16 | ||
11 | |||
12 | 14 -- `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 deleted file mode 120000 index 34aea7f..0000000 --- a/ws2015/EiP/blaetter/02/H2-3.java +++ /dev/null | |||
@@ -1 +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 deleted file mode 100644 index 9cec2d1..0000000 --- a/ws2015/EiP/blaetter/02/manifest +++ /dev/null | |||
@@ -1,3 +0,0 @@ | |||
1 | H2-1.pdf | ||
2 | H2-2.pdf | ||
3 | H2-3.java \ No newline at end of file | ||
diff --git a/ws2015/EiP/blaetter/02/test.sh b/ws2015/EiP/blaetter/02/test.sh deleted file mode 100644 index 5647e13..0000000 --- a/ws2015/EiP/blaetter/02/test.sh +++ /dev/null | |||
@@ -1,20 +0,0 @@ | |||
1 | #!/usr/bin/env zsh | ||
2 | |||
3 | runTest() { | ||
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 | |||
16 | gup --update Arithmetik.class || exit 1 | ||
17 | |||
18 | runTest "Christian\nElegans\n2\n7" "Hallo C. Elegans! Der Mittelwert von 2 und 7 ist übrigens 4.5!" | ||
19 | runTest "Gustav\nEnauer\n70\n15" "Hallo G. Enauer! Der Kehrwert von 70 ist ungefähr 0.014285714285714!" | ||
20 | runTest "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 deleted file mode 100644 index bb3d2ca..0000000 --- a/ws2015/EiP/blaetter/03/H3-1.md +++ /dev/null | |||
@@ -1,39 +0,0 @@ | |||
1 | --- | ||
2 | header-includes: | ||
3 | - \usepackage{bussproofs} | ||
4 | - \renewcommand{\implies}{\rightarrow} | ||
5 | - \EnableBpAbbreviations | ||
6 | --- | ||
7 | # Hoare-Tripel II | ||
8 | |||
9 | d) | ||
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 | |||
22 | e) Nimm als Gegenbeispiel: | ||
23 | |||
24 | ~~~ | ||
25 | a = -1 | ||
26 | b = 0 | ||
27 | ~~~ | ||
28 | |||
29 | f) 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 deleted file mode 100644 index 62d8fc2..0000000 --- a/ws2015/EiP/blaetter/03/H3-2.md +++ /dev/null | |||
@@ -1,84 +0,0 @@ | |||
1 | --- | ||
2 | header-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 | |||
18 | Wir bezeichnen mit $P'$: | ||
19 | |||
20 | ~~~ | ||
21 | a = a + c | ||
22 | b = b + 1 | ||
23 | c = c + 6*b | ||
24 | ~~~ | ||
25 | |||
26 | Wir bezeichnen mit $J$: | ||
27 | |||
28 | ~~~ | ||
29 | a = 0 | ||
30 | b = 0 | ||
31 | c = 1 | ||
32 | ~~~ | ||
33 | |||
34 | und setzen $J'$ derart, dass $\{\} J \{J'\}$ gültig ist. | ||
35 | |||
36 | Wir bezeichnen zudem mit $\bar P$: | ||
37 | |||
38 | ~~~ | ||
39 | while (b != n) { | ||
40 | a = a + c | ||
41 | b = b + 1 | ||
42 | c = c + 6*b | ||
43 | } | ||
44 | ~~~ | ||
45 | |||
46 | Es 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 | |||
70 | Es bleibt zu zeigen, dass $a(n) = n^3$. | ||
71 | Es gilt wegen $P'$ und $J$: | ||
72 | \begin{align*} | ||
73 | c(0) &= 1 \\ | ||
74 | c(k) &= c(k - 1) + 6 \cdot k \\ | ||
75 | &= 1 + \sum_{i = 0}^{k} 6i \\ | ||
76 | a(0) &= 0 \\ | ||
77 | a(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 deleted file mode 100644 index ca9fbd8..0000000 --- a/ws2015/EiP/blaetter/03/H3-3.md +++ /dev/null | |||
@@ -1,33 +0,0 @@ | |||
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 deleted file mode 100644 index ff79ea4..0000000 --- a/ws2015/EiP/blaetter/03/manifest +++ /dev/null | |||
@@ -1,3 +0,0 @@ | |||
1 | H3-1.pdf | ||
2 | H3-2.pdf | ||
3 | H3-3.pdf \ No newline at end of file | ||