From 47e91aea8b8422c407e9a08d53d933ead487564d Mon Sep 17 00:00:00 2001 From: moonleay Date: Wed, 20 Nov 2024 18:58:57 +0100 Subject: [PATCH] chore: improved naming --- main.cpp | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/main.cpp b/main.cpp index 76e0b96..025cf73 100644 --- a/main.cpp +++ b/main.cpp @@ -25,44 +25,44 @@ int main() continue; } - int first_digit = input % 10; - int last_two_digits = input % 100; - int middle_digit = ((last_two_digits) - first_digit) / 10; + const int right_digit = input % 10; + const int middle_and_right_digit = input % 100; + const int middle_digit = ((middle_and_right_digit) - right_digit) / 10; vector result; - string suffix = ""; - if (last_two_digits < 11 || last_two_digits > 12) + string number_construction = ""; + if (middle_and_right_digit < 11 || middle_and_right_digit > 12) { // Handle everything else - if (first_digit == 1) - suffix = "s"; - if (middle_digit > 1 && first_digit != 0) - suffix = "und"; - suffix = first_digit_strings[first_digit] + suffix; + if (right_digit == 1) + number_construction = "s"; + if (middle_digit > 1 && right_digit != 0) + number_construction = "und"; + number_construction = first_digit_strings[right_digit] + number_construction; } else { // Handle 11 and 12 - if (last_two_digits == 11) - suffix = "elf"; + if (middle_and_right_digit == 11) + number_construction = "elf"; else - suffix = "zwoelf"; + number_construction = "zwoelf"; } - result.push_back(suffix); + result.push_back(number_construction); - if ((input > 9 /*input_length > 1*/) && (last_two_digits < 11 || last_two_digits > 12)) + if ((input > 9 /*input_length > 1*/) && (middle_and_right_digit < 11 || middle_and_right_digit > 12)) result.push_back(middle_digit_strings[middle_digit]); else result.push_back(""); if (input > 99 /*input_length >= 3*/) { - int last_digit = ((input % 1000) - middle_digit) / 100; - if (last_digit != 1) - suffix = first_digit_strings[last_digit]; + int left_digit = ((input % 1000) - middle_digit) / 100; + if (left_digit != 1) + number_construction = first_digit_strings[left_digit]; else - suffix = ""; - result.push_back(suffix + "hundert"); + number_construction = ""; + result.push_back(number_construction + "hundert"); } else result.push_back("");