写一个宏可以将一个数字的奇数位和偶数位交换

来源:互联网 发布:java定义数组并赋值 编辑:程序博客网 时间:2024/06/09 23:50
//}#include <stdio.h>#include <stdlib.h>#define Swap(NUM)\    (((NUM & 0xaaaaaaaa) >> 1) + ((NUM & 0x55555555) << 1))      //偶位右移换奇位              //奇位左移换偶位int main(){    int num = 0;    scanf("%d", &num);    int c = Swap(num);    printf("%d\n",c);    system("pause");    return 0;}
0 0
原创粉丝点击