On Mon, 7 May 2007, Andre Poenitz wrote:

How is the syntax in C++ for this logic:

if (
    (a == 1) && (b == 1) &&
    ((C == 1) || (C == -1))
   )

I mean how can the OR be included into an AND?

The only or-less version I can think of is

  if (a == 1 && b == 1 && C*C == 1)

But that's a bit too obfuscated for my taste...

How about:

        if ( a==1 && b==1 && abs(C)==1 )

But what's the point of loosing the OR? I find Uwe's original version easy to read?

/Christian

--
Christian Ridderström, +46-8-768 39 44               http://www.md.kth.se/~chr

Reply via email to