#include<stdio.h>
int main()
{
int a,b=0xAAAAAAAA,c=0x55555555;
scanf("%d",&a);
a=((a&b)>>1)+((a&c)<<1);
printf("%d",a);
}________________________________ From: sudhir mishra <[email protected]> To: [email protected] Sent: Fri, 12 November, 2010 1:42:46 PM Subject: Re: [algogeeks] Learn Write a program to swap odd and even bits in an unsigned integer with as few instructions as possible (e.g., bit 0 and bit 1 are swapped, bit 2 and bit 3 are swapped, etc). eg.... input--- 1234567 7654321 888 output-- 2222411 12109682 948 -- regards Sudhir Mishra MNNIT ALLAHABAD -- 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. -- 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.
