主题:[讨论]请教二维数组安bit位旋转的办法
如何把下面的数组按照bit旋转90度:
unsigned char buff[8][96]=
{
{0x00,0xE0,0x55,0x24,……},
{0x10,0x24,0x35,0x00,……},
{0xFF,0x66,0x00,0x74,……},
{0x21,0x78,0x23,0x89,……},
{0x20,0xE0,0x66,0x11,……},
{0x03,0x00,0x98,0x29,……},
{0x80,0x78,0x00,0x84,……},
{0x43,0x11,0x12,0x24,……}
}
旋转的例子:
数组A[8]={0x40,0x27,0x24,0x01,0x81,0x56,0x50,0x10}转换成
数组B[8]={0x10,0x61,0x06,0xe0,0x00,0x26,0x22,0x1a}
要求把横向排列转为纵向排列变为B数组B[8],如:
A[0]=0X40= 0 1 0 0 0 0 0 0 B[0]=0001 0000
A[1]=0X27= 0 0 1 0 0 1 1 1 B[1]=0110 0001
A[2]=0X24= 0 0 1 0 0 1 0 0 B[2]=0000 0110
A[3]=0X01= 0 0 0 0 0 0 0 1 B[3]=1110 0000
A[4]=0X81= 1 0 0 0 0 0 0 1 B[4]=0000 0000
A[5]=0X56= 0 1 0 1 0 1 1 0 B[5]=0010 0110
A[6]=0X50= 0 1 0 1 0 0 0 0 B[6]=0010 0010
A[7]=0X10= 0 0 0 1 0 0 0 0 B[7]=0001 1010
即把数组A旋转90度成数组B,按照bit位旋转。
请这里的高手支个招,谢谢先。
unsigned char buff[8][96]=
{
{0x00,0xE0,0x55,0x24,……},
{0x10,0x24,0x35,0x00,……},
{0xFF,0x66,0x00,0x74,……},
{0x21,0x78,0x23,0x89,……},
{0x20,0xE0,0x66,0x11,……},
{0x03,0x00,0x98,0x29,……},
{0x80,0x78,0x00,0x84,……},
{0x43,0x11,0x12,0x24,……}
}
旋转的例子:
数组A[8]={0x40,0x27,0x24,0x01,0x81,0x56,0x50,0x10}转换成
数组B[8]={0x10,0x61,0x06,0xe0,0x00,0x26,0x22,0x1a}
要求把横向排列转为纵向排列变为B数组B[8],如:
A[0]=0X40= 0 1 0 0 0 0 0 0 B[0]=0001 0000
A[1]=0X27= 0 0 1 0 0 1 1 1 B[1]=0110 0001
A[2]=0X24= 0 0 1 0 0 1 0 0 B[2]=0000 0110
A[3]=0X01= 0 0 0 0 0 0 0 1 B[3]=1110 0000
A[4]=0X81= 1 0 0 0 0 0 0 1 B[4]=0000 0000
A[5]=0X56= 0 1 0 1 0 1 1 0 B[5]=0010 0110
A[6]=0X50= 0 1 0 1 0 0 0 0 B[6]=0010 0010
A[7]=0X10= 0 0 0 1 0 0 0 0 B[7]=0001 1010
即把数组A旋转90度成数组B,按照bit位旋转。
请这里的高手支个招,谢谢先。