#include <iostream>  
namespace std;  
   3:   
// 能表示42亿+的无符号整数  
   5:  
//数组长度,0-40亿  
const Bit32 thirtytwo=32;  
   8:    
void createArray(Bit32 *&arr)  
  10: {  
new Bit32[maxLen];  
sizeof(arr));  
  13: }  
  14:  
bool setBit(Bit32 *arr,Bit32 num)  
  16: {  
if(((arr[num/thirtytwo])&(1<<(thirtytwo-num%thirtytwo-1)))==0)  
  18:   {  
  19:      arr[num/thirtytwo]|=1<<(thirtytwo-num%thirtytwo-1);  
return true;  
  21:   }  
else  
  23:   {  
return false;  
  25:    }  
  26: }  
  27:   
int main()  
  29: {  
  30:    Bit32 *s;  
  31:    createArray(s);  
if(!setBit(s,5))  
  33:    {  
<<endl;  
  35:    }  
if(!setBit(s,64))  
  37:    {  
<<endl;  
  39:    }  
if(!setBit(s,1))  
  41:    {  
<<endl;  
  43:    }  
  44:  
return 0;  
  46: }  

相关文章:

  • 2022-12-23
  • 2022-01-10
  • 2022-12-23
  • 2021-11-23
  • 2021-10-24
  • 2021-12-16
猜你喜欢
  • 2022-12-23
  • 2021-06-06
  • 2022-12-23
  • 2021-08-20
  • 2021-06-26
  • 2021-09-05
相关资源
相似解决方案