Re: [algogeeks] swap objects without temp variable

2012-11-12 Thread Dave
@Shivam: Your one-line "solution" violates the sequence point rule. Hence, it is non-standard, and the result is compiler dependent. Dave On Monday, November 5, 2012 9:36:12 AM UTC-6, Shivam...aka Bboy rullz... wrote: > in a single line > a^=b^=a^=b; > > On 05/11/2012, atul anand > wrot

Re: [algogeeks] swap objects without temp variable

2012-11-12 Thread bharat b
+1 umer .. question is to swap for objects .. how do u define '+' on objects(which may contain any type, even dynamic memory allocation). On Mon, Nov 5, 2012 at 9:06 PM, Shivam Rohilla < rohillashivam.jade...@gmail.com> wrote: > in a single line > a^=b^=a^=b; > > On 05/11/2012, atul anand wrote:

Re: [algogeeks] swap objects without temp variable

2012-11-05 Thread Shivam Rohilla
in a single line a^=b^=a^=b; On 05/11/2012, atul anand wrote: > a=a^b; > b=a^b; > a=a^b; > > need to check if a and b are equal or not , bcozz a^a =0 > > On Mon, Nov 5, 2012 at 2:02 AM, manish wrote: > >> Swapping two objects (not integers/chars),without using temp...? >> my solution is using xo

Re: [algogeeks] swap objects without temp variable

2012-11-05 Thread Abhishek Jha
yep its right.one mre method will be a=a+b; b=a-b; a=a-b; On Mon, Nov 5, 2012 at 2:02 AM, manish wrote: > Swapping two objects (not integers/chars),without using temp...? > my solution is using xor operation..is that right and ny other solutions ? > > -- > You received this message be

Re: [algogeeks] swap objects without temp variable

2012-11-05 Thread vaibhav shukla
XOR option wont work for floating points so being generic, using temp variable is the best option for swapping. Anyways, the question requirement was to swap without temp, hence above given solutions go right. On Mon, Nov 5, 2012 at 10:43 AM, atul anand wrote: > a=a^b; > b=a^b; > a=a^b; > > nee

Re: [algogeeks] swap objects without temp variable

2012-11-04 Thread atul anand
a=a^b; b=a^b; a=a^b; need to check if a and b are equal or not , bcozz a^a =0 On Mon, Nov 5, 2012 at 2:02 AM, manish wrote: > Swapping two objects (not integers/chars),without using temp...? > my solution is using xor operation..is that right and ny other solutions ? > > -- > You received this

[algogeeks] swap objects without temp variable

2012-11-04 Thread manish
Swapping two objects (not integers/chars),without using temp...? my solution is using xor operation..is that right and ny other solutions ? -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To view this discussion on the web visit https://grou

Re: [algogeeks] Swap the LSB and MSB within themself of given no.

2010-11-20 Thread coolfrog$
Divesh Dixt sorry last output should be 0xEC... On Sun, Nov 21, 2010 at 9:11 AM, Divesh Dixit < dixit.coolfrog.div...@gmail.com> wrote: > assuming all are 8bit no. > input = 0x46 (0100 0110) > output = 0x26 ( 0010 0110 ) > input = 0x75 (0111 0101) > output = 0xFC (1110 1010 ) > > Algorithm

[algogeeks] Swap the LSB and MSB within themself of given no.

2010-11-20 Thread Divesh Dixit
assuming all are 8bit no. input = 0x46 (0100 0110) output = 0x26 ( 0010 0110 ) input = 0x75 (0111 0101) output = 0xFC (1110 1010 ) Algorithm..??? -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to alg

Re: [algogeeks] Swap the bits

2010-06-21 Thread mohit ranjan
@Amit char foo=157;//10 01 11 01 unsigned char temp; unsigned char base=1; int i; for(i=7; i>0; i=i-2) { temp=foo & (base<>1); // setting the 6th, 4th, 2nd, 0th from temp } printf("%d\n", foo);hope it works :) o/p foo=110 // 01 10 11 10 Mohit On Mon, Jun 21, 2010 at 5:37 PM, am

[algogeeks] Swap the bits

2010-06-21 Thread amit
Given a byte, write a code to swap every two bits. [Using bit operators] Eg: Input: 10 01 11 01 Output: 01 10 11 10 -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to algoge...@googlegroups.com. To unsubscrib

[algogeeks] swap every two bits in the byte..

2009-09-05 Thread Gokul
how ll u swap every two bits in the a byte??? can anyone help me??? for eg. consider a byte as input... 10111010 output should be 01110101 it exactly swap the two bits(no complement is takesplace here).. --~--~-~--~~~---~--~~ You received this message because you

[algogeeks] swap

2006-03-08 Thread anil kumar N R
tell me the four methods for swapping two numbers without a third variable? --~--~-~--~~~---~--~~ 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