c语言7-8 数组循环左移,如何将一个数组的元素循环左移?

该楼层疑似违规已被系统折叠 隐藏此楼查看此楼

#include 

#include 

#define SIZE(a) (sizeof(a)/sizeof(a[0]))

#define HBIT(a) ((a & 0x00000080) != 0)

#define LBIT(a) ((a & 0x00000001) != 0)

int TAB[] = {

0x10, 0x71, 0x12, 0x10, 0x10, 0x7C, 0x00, 0x00,

0x00, 0x00, 0x00, 0x3C, 0x42, 0x42, 0x42, 0x04,

0x04, 0x08, 0x10, 0x20, 0x42, 0x7E, 0x00, 0x00,

0x00, 0x00, 0x00, 0x3C, 0x42, 0x42, 0x04, 0x18,

0x04, 0x02, 0x02, 0x42, 0x44, 0x38, 0x00, 0x00,

0x00, 0x00, 0x00, 0x04, 0x0C, 0x14, 0x24, 0x24,

0x44, 0x44, 0x7E, 0x04, 0x04, 0x1E, 0x00, 0x00,

0x00, 0x00, 0x00, 0x7E, 0x40, 0x40, 0x40, 0x58,

0x64, 0x02, 0x02, 0x42, 0x44, 0x38, 0x00, 0x00,

0x00, 0x00, 0x00, 0x1C, 0x24, 0x40, 0x40, 0x58,

0x64, 0x42, 0x42, 0x42, 0x24, 0x18, 0xC0, 0xDE

};

void Move()

{

int i, j, len;

len = SIZE(TAB);

for(i = 0; i 

{

j = i ? (i - 1) : (len - 1);

if(HBIT(TAB[i]) != LBIT(TAB[j]))

TAB[j] = (unsigned int)TAB[j] ^ 0X00000001;

TAB[i] = (unsigned int)TAB[i] <

TAB[i] = (unsigned int)TAB[i] & 0X000000FF;

TAB[j] = (unsigned int)TAB[j] & 0X000000FF;

}

printf("%#04X, %#04X\n", TAB[0], TAB[1]);

}

int main(void)

{

printf("%#04X, %#04X\n", TAB[0], TAB[1]);

while(TAB[0] != 0XC0 || TAB[1] != 0XDE)

Move();

system("PAUSE");

return EXIT_SUCCESS;

}

你可能感兴趣的:(c语言7-8,数组循环左移)