feat: started handling special cases

This commit is contained in:
moonleay 2024-11-18 17:27:55 +01:00
parent bd53595595
commit 5c2ea4c07b
Signed by: moonleay
GPG key ID: 82667543CCD715FB

View file

@ -24,19 +24,30 @@ int main()
} }
int input_length = static_cast<int>(std::to_string(input).length()); int input_length = static_cast<int>(std::to_string(input).length());
int first_digit = input % 10; int first_digit = input % 10;
vector<string> result;
result.push_back(first_digit_strings[first_digit]);
int middle_digit = ((input % 100) - first_digit) / 10; int middle_digit = ((input % 100) - first_digit) / 10;
vector<string> result;
string suffix = "";
if (first_digit == 1)
suffix = "s";
if (middle_digit != 0 && first_digit != 0)
suffix = "und";
result.push_back(first_digit_strings[first_digit] + suffix);
if (input_length > 1)
result.push_back(middle_digit_strings[middle_digit]); result.push_back(middle_digit_strings[middle_digit]);
else
result.push_back("");
if (input_length == 3) if (input_length == 3)
{ {
int last_digit = ((input % 1000) - middle_digit) / 100; int last_digit = ((input % 1000) - middle_digit) / 100;
result.push_back(first_digit_strings[last_digit] + "hundert"); string suffix = "";
result.push_back(first_digit_strings[last_digit] + "hundert" + suffix);
} }
else
result.push_back("");
cout << result[2] << result[0] << "und" << result[1] << "\n"; cout << result[2] << result[0] << result[1] << "\n";
} }
cout << "Eingabe beendet.\n"; cout << "Eingabe beendet.\n";
return 0; return 0;