chore: improved naming

This commit is contained in:
moonleay 2024-11-20 18:58:57 +01:00
parent 8d3c8f2152
commit 47e91aea8b
Signed by: moonleay
GPG key ID: 82667543CCD715FB

View file

@ -25,44 +25,44 @@ int main()
continue; continue;
} }
int first_digit = input % 10; const int right_digit = input % 10;
int last_two_digits = input % 100; const int middle_and_right_digit = input % 100;
int middle_digit = ((last_two_digits) - first_digit) / 10; const int middle_digit = ((middle_and_right_digit) - right_digit) / 10;
vector<string> result; vector<string> result;
string suffix = ""; string number_construction = "";
if (last_two_digits < 11 || last_two_digits > 12) if (middle_and_right_digit < 11 || middle_and_right_digit > 12)
{ {
// Handle everything else // Handle everything else
if (first_digit == 1) if (right_digit == 1)
suffix = "s"; number_construction = "s";
if (middle_digit > 1 && first_digit != 0) if (middle_digit > 1 && right_digit != 0)
suffix = "und"; number_construction = "und";
suffix = first_digit_strings[first_digit] + suffix; number_construction = first_digit_strings[right_digit] + number_construction;
} }
else else
{ {
// Handle 11 and 12 // Handle 11 and 12
if (last_two_digits == 11) if (middle_and_right_digit == 11)
suffix = "elf"; number_construction = "elf";
else 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]); result.push_back(middle_digit_strings[middle_digit]);
else else
result.push_back(""); result.push_back("");
if (input > 99 /*input_length >= 3*/) if (input > 99 /*input_length >= 3*/)
{ {
int last_digit = ((input % 1000) - middle_digit) / 100; int left_digit = ((input % 1000) - middle_digit) / 100;
if (last_digit != 1) if (left_digit != 1)
suffix = first_digit_strings[last_digit]; number_construction = first_digit_strings[left_digit];
else else
suffix = ""; number_construction = "";
result.push_back(suffix + "hundert"); result.push_back(number_construction + "hundert");
} }
else else
result.push_back(""); result.push_back("");