C hack for storing a bit that takes 1 bit space?

后端 未结 5 1699
误落风尘
误落风尘 2021-02-05 18:14

I have a long list of numbers between 0 and 67600. Now I want to store them using an array that is 67600 elements long. An element is set to 1 if a number was in the set and it

5条回答
  •  没有蜡笔的小新
    2021-02-05 18:58

    If you want to write it in C, have an array of char that is 67601 bits in length (67601/8 = 8451) and then turn on/off the appropriate bit for each value.

提交回复
热议问题