Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
你好我有一个二维array[8][8]的,元素填充要么1要么0。所以我的问题是:如何将一整行转换为 8 位长的无符号整数?
array[8][8]
1
0
我正在用 C 编写代码。
像这样:
int array[8][8]; /* this is what you have */ unsigned row0 = 0; int i; for( i = 0; i < 8; i++ ) row0 |= (unsigned)array[0][i] << i; /* row0 now contains the converted number */
这假设您的数据首先是最低有效位。