chore: improved naming
This commit is contained in:
parent
8d3c8f2152
commit
47e91aea8b
1 changed files with 20 additions and 20 deletions
40
main.cpp
40
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<string> 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("");
|
||||
|
|
Loading…
Reference in a new issue