From 461d4e60854b2b0ec77f093200ee8621698b7b04 Mon Sep 17 00:00:00 2001 From: Mathias Wagner Date: Wed, 15 Nov 2023 12:19:57 +0100 Subject: [PATCH] Updated the solution --- units/2023_11_15/solution_2.cpp | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/units/2023_11_15/solution_2.cpp b/units/2023_11_15/solution_2.cpp index 66db022..163d710 100644 --- a/units/2023_11_15/solution_2.cpp +++ b/units/2023_11_15/solution_2.cpp @@ -10,16 +10,13 @@ int main() { getline(cin, input); - vector parts; - boost::split(parts, input, boost::is_any_of(" ")); - - cout << parts[0] << " - Länderkennziffer (40 = Deutschland)" << endl; - cout << parts[1] << " - Kennzeichen des Herstellers" << endl; - cout << parts[2] << "- Produktkennziffer" << endl; - cout << parts[3] << " - Prüfziffer" << endl; - input.erase(std::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; + for (int i = 0; i < 12; i += 2) { summe1 += (input[i] - '0'); summe2 += (input[i + 1] - '0');