#include<stdio.h>
#include<stdlib.h>
int main()
{
int i=0,j;
int n;
scanf("%d",&n);
for(i=0;i<31;i++){
if(!((1<<i) & n)){
n=(1<<i)^n;
break;
}else{
n=(1<<i)^n;
}
}
printf("%d\n",n);
return 0;
}
On Wed, Jun 23, 2010 at 9:35 PM, vijay <[email protected]> wrote:
> Find the next number for a given number without using any arithmetic
> operators(use bit operations)
>
> --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected]<algogeeks%[email protected]>
> .
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>
>
--
You received this message because you are subscribed to the Google Groups
"Algorithm Geeks" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/algogeeks?hl=en.