From 134673e057fd05e69b29a9076e9d0a7d75da9dc3 Mon Sep 17 00:00:00 2001 From: Mathias Wagner Date: Thu, 16 Nov 2023 12:09:40 +0100 Subject: [PATCH] Updated the solution_2.cpp --- units/2023_11_15/solution_2.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/units/2023_11_15/solution_2.cpp b/units/2023_11_15/solution_2.cpp index 163d710..016ea99 100644 --- a/units/2023_11_15/solution_2.cpp +++ b/units/2023_11_15/solution_2.cpp @@ -1,22 +1,24 @@ #include -#include #include using namespace std; int main() { string input; - int summe1, summe2, gesamt; + long summe1, summe2, gesamt; getline(cin, input); - input.erase(std::remove_if(input.begin(), input.end(), ::isspace), input.end()); + input.erase(remove_if(input.begin(), input.end(), ::isspace), input.end()); cout << input.substr(0, 2) << " - Länderkennziffer (40 = Deutschland)" << endl; cout << input.substr(2, 5) << " - Kennzeichen des Herstellers" << endl; cout << input.substr(7, 5) << "- Produktkennziffer" << endl; cout << input[12] << " - Prüfziffer" << endl; + summe1 = 0; + summe2 = 0; + for (int i = 0; i < 12; i += 2) { summe1 += (input[i] - '0'); summe2 += (input[i + 1] - '0');