Title Description
For a 01-string length of 5 bits, each bit can be 0 or 1, a total of 32 possible. The first few of them are:
00000
00001
00010
00011
00100
Please output these 32 kinds of 01 strings in order from small to large.
Input format
This question is not entered.
Output format
Output 32 rows, in order from small to large, each line is a length of 5 01 strings.
Sample output
00000
00001
00010
00011
00100
< The following sections omit >
public class Main {public static void main (string[] args) {//scanner cin = new Scanner (system.in); int n1=0,n2=0,n3=0,n4=0, n5=0;for (int i=0;i<32;i++) {if (i%2==0) N1=0;else n1=1;if (i/2%2==0) n2=0;else n2=1;if (i/4%2==0) n3=0;else n3=1;if (i/ 8%2==0) N4=0;else n4=1;if (i/16%2==0) N5=0;else n5=1; System.out.println (n5+ "" +n4+ "" +n3+ "" +n2+ "" +n1);}}}
<pre name= "code" class= "Java" >public class main {public static void Main (string[] args) {//Scanner cin = new Scanne R (system.in); string[] n = new String[5];for (int i = 0; i <; i++) {int II = i;for (int j = 0; J < 5; J + +) {n[j]=ii%2+ ""; ii = i I/2;} System.out.println (N[4]+n[3]+n[2]+n[1]+n[0]);}}
Blue Bridge Cup: basic exercise 01 String "Java Algorithm implementation"