From 9c8f8a9fbf200415542973982bb978e82e03226d Mon Sep 17 00:00:00 2001 From: Mathias Wagner Date: Thu, 30 Nov 2023 09:16:02 +0100 Subject: [PATCH] Uploaded new units --- units/2023_11_23/README.md | 5 +++++ units/2023_11_23/solution.cpp | 28 ++++++++++++++++++++++++++ units/2023_11_30/README.md | 7 +++++++ units/2023_11_30/solution_1.cpp | 35 +++++++++++++++++++++++++++++++++ 4 files changed, 75 insertions(+) create mode 100644 units/2023_11_23/README.md create mode 100644 units/2023_11_23/solution.cpp create mode 100644 units/2023_11_30/README.md create mode 100644 units/2023_11_30/solution_1.cpp diff --git a/units/2023_11_23/README.md b/units/2023_11_23/README.md new file mode 100644 index 0000000..f2b0106 --- /dev/null +++ b/units/2023_11_23/README.md @@ -0,0 +1,5 @@ +# Übung 30.11.2023 + +## 🥇 Aufgabe 1 + +### 📜 [Solution](solution.cpp) \ No newline at end of file diff --git a/units/2023_11_23/solution.cpp b/units/2023_11_23/solution.cpp new file mode 100644 index 0000000..33e989e --- /dev/null +++ b/units/2023_11_23/solution.cpp @@ -0,0 +1,28 @@ +#include + +using namespace std; + +int main() { + // Variablendeklaration + int Körner = 2400000; + int Entnahme = 1; + int Tage = 0; + + + // Eingabe + cout << "Geben Sie die Anzahl der Körner ein: "; + cin >> Körner; + + // Berechnung + while (Körner > 0) { + Körner -= Entnahme; + Entnahme *= 2; + Tage++; + cout << "Tag " << Tage << " Entnahme " << Entnahme << " Rest " << (Körner > 0 ? Körner : 0) << endl; + } + + // Ausgabe + cout << "Nach " << Tage << " Tagen kann er Ottilie heiraten!" << endl; + + return 0; +} \ No newline at end of file diff --git a/units/2023_11_30/README.md b/units/2023_11_30/README.md new file mode 100644 index 0000000..cf6944d --- /dev/null +++ b/units/2023_11_30/README.md @@ -0,0 +1,7 @@ +# Übung 30.11.2023 + +## 🥇 Aufgabe 1 + +Erstellen Sie anhand des Struktogramms ein Programm! + +### 📜 [Solution](solution_1.cpp) \ No newline at end of file diff --git a/units/2023_11_30/solution_1.cpp b/units/2023_11_30/solution_1.cpp new file mode 100644 index 0000000..9082a04 --- /dev/null +++ b/units/2023_11_30/solution_1.cpp @@ -0,0 +1,35 @@ +#include + +using namespace std; + +int main() { + // Variablendeklaration + int x, y, z; + + // Eingabe + cout << "Bitte geben Sie x ein: "; + cin >> x; + + // Variableninitialisierung + y = 3; + z = x * y; + + // Berechnung + while (x > 0) { + y += 2; + z--; + + if (z > 3) { + z -= 2; + } else { + z += 2; + } + + x--; + } + + // Ausgabe + cout << "x = " << x << endl; + cout << "y = " << y << endl; + cout << "z = " << z << endl; +} \ No newline at end of file