From 8d3c8f21522ebb5e8f4323237dd99fc617dd1088 Mon Sep 17 00:00:00 2001 From: moonleay Date: Wed, 20 Nov 2024 18:43:38 +0100 Subject: [PATCH] feat: use shorter version of 100-s --- main.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/main.cpp b/main.cpp index 8b2261c..76e0b96 100644 --- a/main.cpp +++ b/main.cpp @@ -58,8 +58,11 @@ int main() if (input > 99 /*input_length >= 3*/) { int last_digit = ((input % 1000) - middle_digit) / 100; - string suffix = ""; - result.push_back(first_digit_strings[last_digit] + "hundert" + suffix); + if (last_digit != 1) + suffix = first_digit_strings[last_digit]; + else + suffix = ""; + result.push_back(suffix + "hundert"); } else result.push_back("");