单⽚机c语⾔左环移指令,如何将⼀个数组的元素循环左移?该楼层疑似违规已被系统折叠 隐藏此楼查看此楼
#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;
c语言如何创建字符串数组
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;
}
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。
发表评论