Uploaded new units

This commit is contained in:
2023-11-30 09:16:02 +01:00
parent 52cdef645c
commit 9c8f8a9fbf
4 changed files with 75 additions and 0 deletions

View File

@@ -0,0 +1,5 @@
# Übung 30.11.2023
## 🥇 Aufgabe 1
### 📜 [Solution](solution.cpp)

View 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;
}