哈哈 多谢楼上的 我居然忽略了直接用printf 一直想着要用什么公式~~~ 这样如果是单独输出无限循环简易多了 不过还是解决不了 从Bbit中找出所有包括Abit的值
程序代码:#include <stdio.h>
#include <stdlib.h>
#define A 0xAAAAAAAA
char *bv(char *buf, size_t bufsize, unsigned int n, int wide)
{
char *last = &buf[bufsize];
*last = '\0';
while (wide <= 0 ? n : wide--)
{
*--last = '0' + (n & 1);
n >>= 1;
}
return last;
}
int main(void)
{
#define BUFSIZE 33
#define bv(c, wide) bv(buf, BUFSIZE, (c), (wide))
char buf[BUFSIZE];
int a, b;
while (scanf("%d%d", &a, &b) == 2)
{
int n = 0, bn = 1, orig_n, orig_bn;
while (n < b - a + 1)
{
int c = 0, cc = b - n - a;
orig_n = n;
orig_bn = bn;
while (n > 0)
{
int d;
for (d = 0; d < bn; ++d)
{
printf("%s", bv(c, cc));
printf("%s", bv(A >> (32 - a), -1));
printf("%s\n", bv(d, n));
}
n -= 1;
bn >>= 1;
c = (c << 1) | 1;
cc += 1;
}
printf("%s", bv(c, cc));
printf("%s\n", bv(A >> (32 - a), -1));
n = orig_n + 1;
bn = orig_bn << 1;
}
}
return 0;
#undef bv
#undef BUFSIZE
}







