Re: [algogeeks] Exchanging bit values in a number

2011-09-14 Thread DeVaNsH gUpTa
#include
int main()
{
int n,i,j,temp,temp1;
scanf("%d %d %d",&n,&i,&j);
temp=(1

Re: [algogeeks] Exchanging bit values in a number

2011-09-13 Thread sravanreddy001
@ANKIT: your solution just compliments the bits at given locations... but we 
are looking at swapping 2 different bit locations..

-- 
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/-/YpL4y_eMZd8J.
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, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Exchanging bit values in a number

2011-09-13 Thread kumar raja
@Dave and Gene

sorry , i mean ur solutions are brilliant ,but i did not get those kind of
ideas till now..

On 13 September 2011 12:31, kumar raja  wrote:

> @Dave and Gene
>
> I am totally awkward at ur solutions ...How did u develop these solutions??
> . Can u please quote some material/book on this topic..
>
>
> On 13 September 2011 12:18, Sandy  wrote:
>
>> @Ankit.
>>
>> n= 1101
>>
>> i=2 j=3
>>
>> x = (2^j + 2^i) =  1100
>> x^n =  0001
>>
>> Answer should be  1101.
>>
>> On Wed, Sep 14, 2011 at 12:39 AM, Ankit Agarwal 
>> wrote:
>>
>>> let x = 2^j + 2 ^i
>>> new number after swapping the digits is x XOR n
>>>
>>> eg n =  1101
>>> j = 6 i = 2
>>> x = 0100 0100
>>>  new number = x XOR n = 0100 1001
>>>
>>>
>>> --
>>> Ankit Agarwal
>>> Computer Science & Engg.
>>> Integrated Dual Degree, V yr
>>> Department of Electronics & Computer Engineering
>>> Indian Institute of Technology Roorkee
>>> Ph. no. +91-9580098805
>>>
>>>  --
>>> 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, visit this group at
>>> http://groups.google.com/group/algogeeks?hl=en.
>>>
>>
>>
>>
>> --
>>
>> *Sandeep Kumar,*
>>  ( Mobile +91-9866507368
>>
>> *“I believe in smart work, Believe Me”*
>>
>>
>>  --
>> 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, visit this group at
>> http://groups.google.com/group/algogeeks?hl=en.
>>
>
>
>
> --
> Regards
> Kumar Raja
> M.Tech(SIT)
> IIT Kharagpur,
> 10it60...@iitkgp.ac.in
> 7797137043.
> 09491690115.
>
>


-- 
Regards
Kumar Raja
M.Tech(SIT)
IIT Kharagpur,
10it60...@iitkgp.ac.in
7797137043.
09491690115.

-- 
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, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Exchanging bit values in a number

2011-09-13 Thread kumar raja
@Dave and Gene

I am totally awkward at ur solutions ...How did u develop these solutions??
. Can u please quote some material/book on this topic..

On 13 September 2011 12:18, Sandy  wrote:

> @Ankit.
>
> n= 1101
>
> i=2 j=3
>
> x = (2^j + 2^i) =  1100
> x^n =  0001
>
> Answer should be  1101.
>
> On Wed, Sep 14, 2011 at 12:39 AM, Ankit Agarwal wrote:
>
>> let x = 2^j + 2 ^i
>> new number after swapping the digits is x XOR n
>>
>> eg n =  1101
>> j = 6 i = 2
>> x = 0100 0100
>>  new number = x XOR n = 0100 1001
>>
>>
>> --
>> Ankit Agarwal
>> Computer Science & Engg.
>> Integrated Dual Degree, V yr
>> Department of Electronics & Computer Engineering
>> Indian Institute of Technology Roorkee
>> Ph. no. +91-9580098805
>>
>>  --
>> 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, visit this group at
>> http://groups.google.com/group/algogeeks?hl=en.
>>
>
>
>
> --
>
> *Sandeep Kumar,*
>  ( Mobile +91-9866507368
>
> *“I believe in smart work, Believe Me”*
>
>
>  --
> 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, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>



-- 
Regards
Kumar Raja
M.Tech(SIT)
IIT Kharagpur,
10it60...@iitkgp.ac.in
7797137043.
09491690115.

-- 
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, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Exchanging bit values in a number

2011-09-13 Thread Sandy
@Ankit.

n= 1101

i=2 j=3

x = (2^j + 2^i) =  1100
x^n =  0001

Answer should be  1101.

On Wed, Sep 14, 2011 at 12:39 AM, Ankit Agarwal wrote:

> let x = 2^j + 2 ^i
> new number after swapping the digits is x XOR n
>
> eg n =  1101
> j = 6 i = 2
> x = 0100 0100
>  new number = x XOR n = 0100 1001
>
>
> --
> Ankit Agarwal
> Computer Science & Engg.
> Integrated Dual Degree, V yr
> Department of Electronics & Computer Engineering
> Indian Institute of Technology Roorkee
> Ph. no. +91-9580098805
>
>  --
> 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, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>



-- 

*Sandeep Kumar,*
 ( Mobile +91-9866507368

*“I believe in smart work, Believe Me”*

-- 
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, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Exchanging bit values in a number

2011-09-13 Thread Ankit Agarwal
let x = 2^j + 2 ^i
new number after swapping the digits is x XOR n

eg n =  1101
j = 6 i = 2
x = 0100 0100
 new number = x XOR n = 0100 1001


-- 
Ankit Agarwal
Computer Science & Engg.
Integrated Dual Degree, V yr
Department of Electronics & Computer Engineering
Indian Institute of Technology Roorkee
Ph. no. +91-9580098805

-- 
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, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



[algogeeks] Exchanging bit values in a number

2011-09-13 Thread kumar raja
Suppose a number 'n' is given  and two bits positions i,j present in binary
representation of n .

Then how to exchange the contents of the two bits i and j.

E.g. n= 13
its binary representation is  1101 (just for now consider 8 bit number)

i= 2,j=6

o/p : 0100 1001 = 73

please suggest some effective way to do this...

-- 
Regards
Kumar Raja
M.Tech(SIT)
IIT Kharagpur,
10it60...@iitkgp.ac.in
7797137043.
09491690115.

-- 
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, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.