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