#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#define LEN 2000
int a[] = {0, 1, 3, 56, 56, 100, 101, 102, 1000, 2000};
int b[] = {1, 45, 56, 56, 100, 1000};
char bit[LEN];
int clear(char *p, int len);
int setbit(char *p, int n);
int output(char *p, int len);
int main()
{
char c;
c = 1;
clear(bit, LEN);
int i;
for(i = 0; i < sizeof(a) / sizeof(int); i++)
setbit(bit, a[i]);
for(i = 0; i < sizeof(b) / sizeof(int); i++)
setbit(bit, b[i]);
output(bit, LEN);
}
int clear(char *p, int len)
{
memset(p, 0, len);
return 0;
}
int setbit(char *p, int n)
{
int pass = n / 8;
n = n % 8;
p += pass;
n = 7 - n;
*p = *p | (1 << n);
return 0;
}
int output(char *p, int len)
{
int i,k;
char c, t;
for(i = 0; i < len; i++)
{
c = *(p + i);
for(k = 0; k < 8; k++)
{
if((c >> (7 - k)) & 1 == 1)
printf("%d\n", i * 8 + k);
}
}
return 0;
}
|