问题描述
对于长度为5位的一个01串,每一位都可能是0或1,一共有32种可能。它们的前几个是:
00000
00001
00010
00011
00100
请按从小到大的顺序输出这32种01串。
1 #include<iostream> 2 3 using namespace std; 4 5 int main() 6 { 7 for(int a=0;a<=1;a++) 8 for(int b=0;b<=1;b++) 9 for(int c=0;c<=1;c++) 10 for(int d=0;d<=1;d++) 11 for(int e=0;e<=1;e++) 12 { 13 cout<<a<<b<<c<<d<<e<<endl; 14 } 15 16 return 0; 17 }
原文:https://www.cnblogs.com/bilibiliya/p/10303144.html