蓝桥杯练习-基础练习-01字串

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/wordsin/article/details/79766148

蓝桥杯练习-基础练习-01字串

题目链接

问题描述

对于长度为5位的一个01串,每一位都可能是0或1,一共有32种可能。它们的前几个是:
00000
00001
00010
00011
00100
请按从小到大的顺序输出这32种01串。

输入格式

本试题没有输入。

输出格式

输出32行,按从小到大的顺序每行一个长度为5的01串。

样例输出

00000
00001
00010
00011
<以下部分省略>

#

输出

AC代码

#include<iostream>
#include<string>
using namespace std;
string str[32] = {
    "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",
};
int main() {
    std::ios::sync_with_stdio(false);
    for (int i = 0; i <= 31; ++i)
        cout << str[i] << endl;
    return 0;
}

猜你喜欢

转载自blog.csdn.net/wordsin/article/details/79766148