From d11511774db9ad6b718343fe4c90a8aea00f9462 Mon Sep 17 00:00:00 2001 From: Mathias Wagner Date: Mon, 6 Nov 2023 12:49:58 +0100 Subject: [PATCH] Created the solution_7.cpp --- units/2023_10_27/solution_7.cpp | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 units/2023_10_27/solution_7.cpp diff --git a/units/2023_10_27/solution_7.cpp b/units/2023_10_27/solution_7.cpp new file mode 100644 index 0000000..b256d88 --- /dev/null +++ b/units/2023_10_27/solution_7.cpp @@ -0,0 +1,19 @@ +#include + +using namespace std; + +int main() { + // Variablen deklarieren + int Jahr; + bool Schaltjahr; + + // Eingaben einlesen + cout << "Geben Sie eine Jahreszahl ein: "; + cin >> Jahr; + + // Berechnen + Schaltjahr = (Jahr % 4 == 0 && Jahr % 100 != 0) || Jahr % 400 == 0; + + // Ausgabe + cout << "Das Jahr ist " << (Schaltjahr ? "ein " : "kein ") << "Schaltjahr." << endl; +} \ No newline at end of file