循环移位的C语言实现

#include 
#include 

#define crol(n, i) (((n) << (i)) | ((n) >> (8 - (i))))
#define cror(n, i) (((n) >> (i)) | ((n) << (8 - (i))))
#define irol(n, i) (((n) << (i)) | ((n) >> (16 - (i))))
#define iror(n, i) (((n) >> (i)) | ((n) << (16 - (i))))
#define lrol(n, i) (((n) << (i)) | ((n) >> (32 - (i))))
#define lror(n, i) (((n) >> (i)) | ((n) << (32 - (i))))

int main() {
    uint8_t n = 0b10110100;
    n = crol(n, 2);
    printf("%X\n", n);
    return 0;
}

你可能感兴趣的:(程序设计与算法)