Skip to content

Instantly share code, notes, and snippets.

@shihongzhi
Created November 10, 2010 11:36
Show Gist options
  • Save shihongzhi/670735 to your computer and use it in GitHub Desktop.
Save shihongzhi/670735 to your computer and use it in GitHub Desktop.
#include <stdio.h>
#define BITNUMBER 32 //int占4个字节
#define N 32000
int a[N/BITNUMBER+1];
void set(int i)
{
a[i/BITNUMBER]|=1<<(i%BITNUMBER);
}
void clean(int i)
{
a[i/BITNUMBER]&=~1<<(i%BITNUMBER);
}
int test(int i) //显示该位值
{
return (a[i/BITNUMBER]>>(i%BITNUMBER))&1;
}
int main()
{
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment