From 94429c69e1b90241a69af1b7ec648554642252aa Mon Sep 17 00:00:00 2001 From: moonleay Date: Wed, 20 Nov 2024 17:24:44 +0100 Subject: [PATCH] feat!: removed static_cast --- main.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/main.cpp b/main.cpp index 3545741..bddcb5a 100644 --- a/main.cpp +++ b/main.cpp @@ -25,8 +25,7 @@ int main() cout << "Zahl ausserhalb des gueltigen Bereichs.\n"; continue; } - // TODO: remove static_cast - int input_length = static_cast(std::to_string(input).length()); + int first_digit = input % 10; int last_two_digits = input % 100; int middle_digit = ((last_two_digits) - first_digit) / 10; @@ -52,12 +51,12 @@ int main() } result.push_back(suffix); - if (input_length > 1 && (last_two_digits < 11 || last_two_digits > 12)) + if ((input > 9 /*input_length > 1*/) && (last_two_digits < 11 || last_two_digits > 12)) result.push_back(middle_digit_strings[middle_digit]); else result.push_back(""); - if (input_length == 3) + if (input > 99 /*input_length >= 3*/) { int last_digit = ((input % 1000) - middle_digit) / 100; string suffix = "";