free性丰满hd毛多多,久久综合给合久久狠狠狠97色69 ,欧美成人乱码一区二区三区,国产美女久久久亚洲综合,7777久久亚洲中文字幕

0
問答首頁 最新問題 熱門問題 等待回答標(biāo)簽廣場
我要提問

如何創(chuàng)建一個BIT類型的數(shù)組?

如何創(chuàng)建一個BIT類型的數(shù)組?
提問者:dreamAnd 地點:- 瀏覽次數(shù):7358 提問時間:02-20 13:45
我有更好的答案
提 交
9條回答
weilai123 03-02 11:25
bit不是標(biāo)準(zhǔn)c語言支持的類型
gumie7235 02-24 20:10
不標(biāo)準(zhǔn)不要緊
柯景文愛旅游 03-01 14:05
不標(biāo)準(zhǔn)不要緊, Keil C51 支持 bit 變量, 單不支持 bit 數(shù)組, 并不是編譯器解決不了這個問題, 而是因為 51 單片機(jī)不支持 bit 位變量的間接尋址. 沒有合適的指令來操作??bit 數(shù)組.
60user90 02-23 10:27
IAR下的各種芯片支持嗎,現(xiàn)在主要是用stm32,可以搞不?
涸皓云漢芯城 02-23 03:07
人工置頂。求大神!
cauzhxj 02-26 11:27
28182900:你建BIT類型的數(shù)組的目的是什么?
林宇宣55 02-24 06:16
省空間,存一個碼表
yuxiangxyz 02-21 10:22
typedef struct
? ?? ???{
? ?? ?? ?? ?? ? unsigned long int a:1;
? ?? ?? ?? ?? ? unsigned long int b:1;
? ?? ?? ?? ?? ?? ?? ?? ?.
? ?? ?? ?? ?? ?? ?? ?? ?.
? ?? ?? ?? ?? ?? ?? ? 依次類推? ?? ???
? ?? ?? ?? ?? ?? ?? ?? ?.
? ?? ?? ?? ?? ? unsigned long int u:1;
? ?? ?? ?? ?? ? unsigned long int :11;
? ?? ???}A;
? ?? ???
? ?? ???A data[21];
? ?? ?? ?引用時data[3].e就是你所說的a[3][5]




[tr][/tr]


貼上代碼,如果_id值是常數(shù)的話,由于編譯器的優(yōu)化,一般可以產(chǎn)生比較好的代碼,當(dāng)然如果是變量的話,也是支持的
#define BIT_SET(_buf,_id) \
{ ((char *)(buf))[(_id)/(sizeof(char)<<3)] |= 1<<(_id)%(sizeof(char)<<3); }

#define BIT_CLR(_buf,_id) \
{ ((char *)(buf))[(_id)/(sizeof(char)<<3)] &= ~(1<<(_id)%(sizeof(char)<<3)); }

#define BIT_GET(_buf,_id) \
(((char *)(buf))[(_id)/(sizeof(char)<<3)] >> ((_id)%(sizeof(char)<<3))? ?? ???& 0x01)

#define BIT_ROW_MAX? ?21
#define BIT_SET2(_buf,_max,_x,_y) BIT_SET((_buf),((_x)*(_max)+(_y)))
#define BIT_CLR2(_buf,_max,_x,_y) BIT_CLR((_buf),((_x)*(_max)+(_y)))
#define BIT_GET2(_buf,_max,_x,_y) BIT_GET((_buf),((_x)*(_max)+(_y)))

int main(int argc, char* argv[])
{
? ?? ???char buf[256]={0};
? ?? ???int s=5;;
? ?? ???BIT_SET(buf,25);
? ?? ???s = BIT_GET(buf,25);
? ?? ???printf("25=%d\n",s);
? ?? ???BIT_CLR(buf,25);
? ?? ???s = BIT_GET(buf,25);
? ?? ???printf("25=%d\n",s);

? ?? ???BIT_SET2(buf,21,3,2);
? ?? ???BIT_CLR2(buf,21,2,3);
? ?? ???s = BIT_GET2(buf,21,3,2);
? ?? ???printf("2,3=%d\n",s);
? ?? ???BIT_CLR2(buf,21,2,3);
? ?? ???s = BIT_GET2(buf,21,2,3);
? ?? ???printf("2,3=%d\n",s);
? ?? ???printf("Hello World!\n");
? ?? ???return 0;
}

這兩位大神提供了2維bit類型的數(shù)組,無奈我實在是看不懂
cheng8416 02-23 05:09
? ?? ?? ?? ?同頂~~~~~~~~~~~~~~
撰寫答案
提 交
1 / 3
1 / 3