Design a site like this with WordPress.com
Get started

SinhNhiPhan

package practice;

import java.util.Scanner;

public class SinhNhiPhan {
static int n;
static int []arr;
static void result() {
for(int i=0; i<n; i++) {
System.out.print(arr[i]+” “);
}
System.out.println();
}
static void Try(int index) {
for(int j=0; j<=1; j++) {
arr[index] = j;
if(index == n-1) result(); // đến cấu hình cuối cùng thì in ra tất cả, vì từ 0 tới n
// còn index == n thì lại sinh từ đâu
else Try(index+1);
}
}
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
n = sc.nextInt();
arr = new int[n+1];
Try(0);
}

}

Advertisement

Author: alexishuuuocn

I'm a software engineer

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: