Blue Bridge Cup -01 substring (violence)

Subject description:

01 for a run length of 5 bits, each bit may be 0 or 1, a total of 32 possible. They are the first few:
00000
00001
00010
00011
00100

press ascending order of 01 The 32 output string.  

Input: 

This questions is not entered. 

Output: 

Output line 32, in ascending order of a length of each line 01 of the string 5. 

Sample input: 

no 

Sample output: 

00000

00001

00010

00011

<Following sections will be omitted> 

code: 

C / C ++ version: 

#include<stdio.h>
int main()
{
	for(int i=0;i<=1;i++)
	{
		for(int j=0;j<=1;j++)
		{
			for(int k=0;k<=1;k++)
			{
				for(int m=0;m<=1;m++)
				{
					for(int n=0;n<=1;n++)
					{
						printf("%d%d%d%d%d\n",i,j,k,m,n);
					}
				}
			}
		}
	}
	return 0;
}

 Java version:

import java.util.*;
public class Main
{
	public static void main(String[] args)
	{
		for(int i=0;i<=1;i++)
		{
			for(int j=0;j<=1;j++)
			{
				for(int k=0;k<=1;k++)
				{
					for(int m=0;m<=1;m++)
					{
						for(int n=0;n<=1;n++)
						{
							System.out.println(i+""+j+""+k+""+m+""+n);
						}
					}
				}
			}
		}
	}
}

 

Published 277 original articles · won praise 285 · views 20000 +

Guess you like

Origin blog.csdn.net/weixin_43823808/article/details/104113050