return (((-1+!x)&y) | ((-1+!!x)&z)) ;
On Sun, Oct 2, 2011 at 3:18 PM, ravi maggon <[email protected]> wrote: > How about this answer: > b?z:y > > int main() { > int a=0,b,y=4,z=5,k; > cin>>b; > k=(((b+~a+1)>>7)&1);//k will either be 0 or 1 > cout<< (z-int((bool)k&(z-y))); > return 0; > } > > On Mon, Sep 12, 2011 at 5:32 PM, beginner <[email protected]> wrote: >> >> although multiplication operator is not allowed.. >> but it's an attempt to write shorter... >> >> c++ implementation- >> >> int cond(int x, int y, int z){ >> return y*(int)((bool)x)+z*(1+(~(int)((bool)x)+1)); >> } >> >> -- >> You received this message because you are subscribed to the Google Groups >> "Algorithm Geeks" group. >> To view this discussion on the web visit >> https://groups.google.com/d/msg/algogeeks/-/5uGBGvacNEwJ. >> To post to this group, send email to [email protected]. >> To unsubscribe from this group, send email to >> [email protected]. >> For more options, visit this group at >> http://groups.google.com/group/algogeeks?hl=en. > > > > -- > Regards > Ravi Maggon > B.E. CSE, Final Year > Thapar University > > www.algorithmguru.com > > "Failure is the opportunity to begin again more intelligently" > > -- > You received this message because you are subscribed to the Google Groups > "Algorithm Geeks" group. > To post to this group, send email to [email protected]. > To unsubscribe from this group, send email to > [email protected]. > For more options, visit this group at > http://groups.google.com/group/algogeeks?hl=en. > -- Varun Jakhoria ...it's only about 0's & 1's -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
