We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
and notice the signature of parseInts avoiding copying the passed string when calling the function and helping the compiler in any optimization! But I've seen way worse in other exercices ...
For the lulz:
Although it doesn't respect all the requirements of the exercice (e.g. using parseInts), here's a 10-liner getting the job done:
StringStream
You are viewing a single comment's thread. Return to all comments →
Here's my solution:
By the way, why don't we get well-written functions to work with?
main
could look like:instead of
and notice the signature of
parseInts
avoiding copying the passedstring
when calling the function and helping the compiler in any optimization! But I've seen way worse in other exercices ...For the lulz:
Although it doesn't respect all the requirements of the exercice (e.g. using
parseInts
), here's a 10-liner getting the job done:and, even better, a 6-liner only using the standard streams
std::cin
andstd::cout
(nostring
s)!This will be hard to beat ...