蓝桥基础练习 01字串 BASIC-2

问题描述

对于长度为5位的一个01串,每一位都可能是0或1,一共有32种可能。它们的前几个是:

00000

00001

00010

00011

00100

请按从小到大的顺序输出这32种01串。

输入格式

本试题没有输入。

输出格式

输出32行,按从小到大的顺序每行一个长度为5的01串。
样例输出
00000
00001
00010
00011
<以下部分省略>
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdio>
#include <vector>
#include <cmath>
#include <queue>
#include <deque>
#include <cmath>
#include <map>

using namespace std;
typedef long long ll;

#define INF 0x7fffffff
const double inf=1e20;
const int maxn=10000+10;
const int mod=1e9+7;
const double pi=acos(-1);

int main(){
    for(int i=0;i<32;i++){
        printf("%d",i/16%2);
        printf("%d",i/8%2);
        printf("%d",i/4%2);
        printf("%d",i/2%2);
        printf("%d",i%2);
        printf("\n");
    }
    return 0;
}

猜你喜欢

转载自www.cnblogs.com/wz-archer/p/12499413.html