Re: [algogeeks] C Trick

2011-09-13 Thread saurabh agrawal
Priyanka.. ideally u should not use any function calls to solve this question.. because they internally might use conditional operators or if else.. OR u can give your own definition of abs() function With Regards Saurabh On Wed, Aug 24, 2011 at 11:06 PM, priyanka raju priyark...@gmail.comwrote:

Re: [algogeeks] C Trick

2011-09-01 Thread annarao kataru
@priyanka good one -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options,

Re: [algogeeks] C Trick

2011-08-26 Thread saipraneeth
ar[0]=a; ar[1]=b; printf(largest %d,ar[((a-b)31)0x1]); On Wed, Aug 24, 2011 at 11:20 PM, kranthi kumar damarlakran...@gmail.comwrote: @priyanka raju, Good solution... -- Regards: --- D Kranthi kumar Computer Science Engg. IIT Madras. -- You received this

Re: [algogeeks] C Trick

2011-08-24 Thread vikas singh
On Tue, Aug 23, 2011 at 7:50 PM, *$* gopi.komand...@gmail.com wrote: int a,b; int c=a-b; c=c31; c=c31; // hope you're trying for this. ;) int x =c0x01; a=a-x*c; Thx, --Gopi On Tue, Aug 23, 2011 at 7:32 PM, Sanjay Rajpal srn...@gmail.com wrote: @teja : use of comparison operator

Re: [algogeeks] C Trick

2011-08-24 Thread praneethn
*max=(ab)*a+(ba)*b;* On Wed, Aug 24, 2011 at 7:32 PM, vikas singh shyguy1...@gmail.com wrote: On Tue, Aug 23, 2011 at 7:50 PM, *$* gopi.komand...@gmail.com wrote: int a,b; int c=a-b; c=c31; c=c31; // hope you're trying for this. ;) int x =c0x01; a=a-x*c; Thx, --Gopi On Tue,

Re: [algogeeks] C Trick

2011-08-24 Thread vikas singh
On Wed, Aug 24, 2011 at 8:25 PM, praneethn praneeth...@gmail.com wrote: *max=(ab)*a+(ba)*b;* Not allowed ;) Read the constraints applied. -- Thanks and Regards VIKAS SINGH MCA- final year NIT DURGAPUR email: vikas.singh1...@gmail.com shyguy1...@gmail.com http://smrit.wordpress.com -- You

Re: [algogeeks] C Trick

2011-08-24 Thread Anup Ghatage
Priyanka raju's solution will not work if a = 3 and b = -2 On Wed, Aug 24, 2011 at 8:28 PM, vikas singh shyguy1...@gmail.com wrote: On Wed, Aug 24, 2011 at 8:25 PM, praneethn praneeth...@gmail.com wrote: *max=(ab)*a+(ba)*b;* Not allowed ;) Read the constraints applied. -- Thanks and

Re: [algogeeks] C Trick

2011-08-24 Thread *$*
oops! yes I was trying to find whether that number is negative or positive by shifting the highest bit to oth location... that is a typo error.. Thanks for pointing out! On Wed, Aug 24, 2011 at 7:32 PM, vikas singh shyguy1...@gmail.com wrote: On Tue, Aug 23, 2011 at 7:50 PM, *$*

Re: [algogeeks] C Trick

2011-08-24 Thread Abhishek Yadav
@Anup: i think priyanka's solution would work for 3 and -2 On Wed, Aug 24, 2011 at 10:05 PM, *$* gopi.komand...@gmail.com wrote: oops! yes I was trying to find whether that number is negative or positive by shifting the highest bit to oth location... that is a typo error.. Thanks for

Re: [algogeeks] C Trick

2011-08-24 Thread Anup Ghatage
Please explain with the example, I just joined, so I may have missed the earlier details :) On Wed, Aug 24, 2011 at 10:11 PM, Abhishek Yadav algowithabhis...@gmail.com wrote: @Anup: i think priyanka's solution would work for 3 and -2 On Wed, Aug 24, 2011 at 10:05 PM, *$*

Re: [algogeeks] C Trick

2011-08-24 Thread priyanka raju
It will work... a=3 b=-2 max=(a+b+abs(a-b))/2 so max=(3-2+abs(3-(-2)))/2 =(1+abs(5))/2 =(1+5)/2 =3 Same in case of min -- cheers priyanka -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send

Re: [algogeeks] C Trick

2011-08-24 Thread kranthi kumar
@priyanka raju, Good solution... -- Regards: --- D Kranthi kumar Computer Science Engg. IIT Madras. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To

[algogeeks] C Trick

2011-08-23 Thread Abhishek Yadav
Write a method which finds the maximum of two numbers You should not use if-else or any other comparison operator. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe

Re: [algogeeks] C Trick

2011-08-23 Thread sukran dhawan
http://stackoverflow.com/questions/4772780/find-the-maximum-of-two-numbers-without-using-if-else-or-any-other-comparison-ope On Tue, Aug 23, 2011 at 6:37 PM, Abhishek Yadav algowithabhis...@gmail.comwrote: Write a method which finds the maximum of two numbers You should not use if-else or

Re: [algogeeks] C Trick

2011-08-23 Thread teja bala
int a,b,c; c=(ab)?a:b; print(c); On Tue, Aug 23, 2011 at 6:37 PM, Abhishek Yadav algowithabhis...@gmail.comwrote: Write a method which finds the maximum of two numbers You should not use if-else or any other comparison operator. -- You received this message because you are subscribed to

Re: [algogeeks] C Trick

2011-08-23 Thread Sanjay Rajpal
@teja : use of comparison operator is not allowed. Sanju :) On Tue, Aug 23, 2011 at 6:42 AM, teja bala pawanjalsa.t...@gmail.comwrote: int a,b,c; c=(ab)?a:b; print(c); On Tue, Aug 23, 2011 at 6:37 PM, Abhishek Yadav algowithabhis...@gmail.com wrote: Write a method which finds the

Re: [algogeeks] C Trick

2011-08-23 Thread *$*
int a,b; int c=a-b; c=c31; int x =c0x01; a=a-x*c; Thx, --Gopi On Tue, Aug 23, 2011 at 7:32 PM, Sanjay Rajpal srn...@gmail.com wrote: @teja : use of comparison operator is not allowed. Sanju :) On Tue, Aug 23, 2011 at 6:42 AM, teja bala pawanjalsa.t...@gmail.comwrote: int a,b,c;

Re: [algogeeks] C Trick

2011-08-23 Thread Aditya Virmani
subtract the two check if its greater thn 0... c=a-b, if(c 1000 ) printf(a) else printf(b) On Tue, Aug 23, 2011 at 7:50 PM, *$* gopi.komand...@gmail.com wrote: int a,b; int c=a-b; c=c31; int x =c0x01; a=a-x*c; Thx, --Gopi On Tue, Aug 23, 2011 at 7:32 PM, Sanjay Rajpal