From 12dda8d5244e86096a5ea56014073dd1892cc409 Mon Sep 17 00:00:00 2001 From: Oskar Date: Tue, 20 Aug 2024 13:51:53 +0200 Subject: more --- 4p23.cpp | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 4p23.cpp (limited to '4p23.cpp') diff --git a/4p23.cpp b/4p23.cpp new file mode 100644 index 0000000..b53cc84 --- /dev/null +++ b/4p23.cpp @@ -0,0 +1,26 @@ +#include + +/* + * + * 4.23 + * + * + */ + +int main () { + + /* + + Took me a while to figure out + was not so sure what the author + wanted to achieve. I mean there + are several ways we can paranthesize + this so it was a little hard to do... + + */ + + std::string s = "word"; + std::string pl = s + (s[s.size() - 1] == 's' ? "" : "s") ; + std::cout << pl << std::endl; + return 0; +} -- cgit v1.2.3