| 
              问题描述对于长度为5位的一个01串,每一位都可能是0或1,一共有32种可能。它们的前几个是:
 00000
 00001
 00010
 00011
 00100
 请按从小到大的顺序输出这32种01串。
 输入格式
 本试题没有输入。
 输出格式
 输出32行,按从小到大的顺序每行一个长度为5的01串。
 样例输出
 00000
 00001
 00010
 00011
 <以下部分省略>
 
 【我的代码】
 #include <stdio.h>
 
 #define _BV(n) 1<<n
 
 int main()
 {
 int i;
 unsigned char d;
 for (d = 0x00; d <= 0x1f; d++)
 {
 for (i = 4; i >= 0; i--)
 {
 if (d & _BV(i))
 putchar('1');
 else
 putchar('0');
 }
 putchar('\n');
 }
 return 0;
 }
 
 【运行结果】
 00000
 00001
 00010
 00011
 00100
 00101
 00110
 00111
 01000
 01001
 01010
 01011
 01100
 01101
 01110
 01111
 10000
 10001
 10010
 10011
 10100
 10101
 10110
 10111
 11000
 11001
 11010
 11011
 11100
 11101
 11110
 11111
 
 --------------------------------
 Process exited after 0.01928 seconds with return value 0
 Press any key to continue . . .
 
 |