31

I've seen people posting their own convoluted ways to find out whether or not a number is even, so here's mine. :-P

Comments
  • 2
    love the font, what is it?
  • 4
    @calmyourtities Fantasque Sans Mono I believe.
  • 2
    @Bitwise I think you missed the point of it being as convoluted as possible on purpose. :-P
  • 1
    @Julien00859 if I saw that in a code base I would immediately shorten it. Vertical space / conciseness is a precious / important thing and that is wasting way too much of it.
  • 2
    @Julien00859 oh I get it now that you mention it. 😅 I guess even when I'm trying to be convoluted there are just certain things that I can't bring myself to do.
  • 5
    @Julien00859

    bool answer;

    if (s[s.length -1] == '0')

    {

    answer = true;

    return (answer == true);

    }

    else if (s[s.length -1] != '0')

    {

    answer = true;

    return (answer != true || answer == false);

    }

    Now it's clear.
  • 2
    The ONLY correct way to get the last element from std string is:

    std::string s = "Hello" ;
    char c= *((&s.at(0)) + (s.size() - 1));
  • 1
    @Batburger I hope that capitals 'only' is sarcasm.
Add Comment