you can try this..
int add(int x, int y)
{
if (!x) return y;
else
return add((x & y) << 1, x ^ y);
}
On Sep 7, 4:01 pm, ritter wrote:
> how to add two integers without using arithmetic operators?
> can anyone help me.
--~--~--
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
Find details related to C/C++ programming languages. From preparing
flowchart and many more. A one stop website for all your programming
language needs
http://www.blogonprogramming.blogspot.com
http://www.sqlserversoftware.blogspot.com
--~--~-~--~~~---~--~~
You re
A one shop website for all your IT needs. Find details regarding
programing languages such as C/C++ and .Net.
http://www.blogonprogramming.blogspot.com
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups
"Algorithm Geeks
kumar wrote:
> kerry wrote:
>
> > need O(n) time
> > the array is set[n],
> > for(i = 1, i <=n ; i++)
> > if((set[i] & 1) & (set[i + 1] & 1))
> > then miss the number i+1;
>
> ur logic is not satisfied for even the array is in sorted order also.
> For sorted array
> we need ( set [ i
yes, it's likely we think it's sorted since Joe uses the word
_sequence_ :
"In a sequence o,f from 1 to n (1,2,3,...n) numbers, we need to find
the
missing numbers. There will not be duplicates."
anyway its a better problem if unsorted...
--~--~-~--~~~---~--~~
Y
girsh and kamlesh: that may work if the (n-1) numbers are integers 1 to
n. What if they can be anything. (from your S(n) = n*(n+1) / 2 ) )
adak : distribution sort - this is effectively the same as the bitmap
thing which Lego Haryanto mentioned in the beginning. (we're only using
a byte or somethi