http://acm.hdu.edu.cn/showproblem.php?pid=2562 奇偶位互换 Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 3824 Accepted Submission(s): 2913 Problem Description 给定一个长度为偶数位的0,1字符串,请编程实现串的奇偶位互换. I…
5.6 Write a program to swap odd and even bits in an integer with as few instructions as possible (e.g., bit 0 and bit 1 are swapped, bit 2 and bit 3 are swapped, and soon). 这道题让我们交换奇偶位,那么我们首先还是要考虑用位操作Bit Manipulation来做,我们知道由于奇偶位是相邻的,奇数位平移一位就是偶数位,反过来偶…