描述
对于长度为5位的一个01串,每一位都可能是0或1,一共有32种可能。它们的前几个是:
00000
00001
00010
00011
00100
请按从小到大的顺序输出这32种01串。
输入
输入描述:
本试题没有输入。
输出
输出描述:
输出32行,按从小到大的顺序每行一个长度为5的01串。
#include <iostream>
using namespace std;
int main()
{
int a[5]={0,0,0,0,0};
int n=0;
while(n!=32)
{
cout<<n/16<<(n%16)/8<<(n%8)/4<<(n%4)/2<<n%2<<endl;
n++;
}
return 0;
}