@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
+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:
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
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
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
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
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
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
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
@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
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
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
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
13 matches
Mail list logo