基础练习 01字串

问题描述

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

00000

00001

00010

00011

00100

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

输入格式
本试题没有输入。
输出格式
输出32行,按从小到大的顺序每行一个长度为5的01串。
样例输出
00000
00001
00010
00011

<以下部分省略>




public class Main {
public static void main(String[] args) {
for (int i = 0; i < 32; i++) {
System.out.print(i % 32 / 16);
System.out.print(i % 16 / 8);
System.out.print(i % 8 / 4);
System.out.print(i % 4 / 2);
System.out.print(i % 2);
System.out.println();
}
}
}

全部评论

相关推荐

今天 11:42
江西农业大学 C++
点赞 评论 收藏
分享
05-16 11:16
已编辑
东华理工大学 Java
牛客73769814...:盲猜几十人小公司,庙小妖风大,咋不叫她去4️⃣呢😁
牛客创作赏金赛
点赞 评论 收藏
分享
评论
1
1
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务