Uploaded new units
This commit is contained in:
parent
52cdef645c
commit
9c8f8a9fbf
5
units/2023_11_23/README.md
Normal file
5
units/2023_11_23/README.md
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
# Übung 30.11.2023
|
||||||
|
|
||||||
|
## 🥇 Aufgabe 1
|
||||||
|
|
||||||
|
### 📜 [Solution](solution.cpp)
|
28
units/2023_11_23/solution.cpp
Normal file
28
units/2023_11_23/solution.cpp
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
#include <iostream>
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
7
units/2023_11_30/README.md
Normal file
7
units/2023_11_30/README.md
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
# Übung 30.11.2023
|
||||||
|
|
||||||
|
## 🥇 Aufgabe 1
|
||||||
|
|
||||||
|
Erstellen Sie anhand des Struktogramms ein Programm!
|
||||||
|
|
||||||
|
### 📜 [Solution](solution_1.cpp)
|
35
units/2023_11_30/solution_1.cpp
Normal file
35
units/2023_11_30/solution_1.cpp
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
#include <iostream>
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user