[BOJ] 6603. 로또
15 Apr 2026
Reading time ~1 minute
풀이
import java.util.Arrays;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
while(true) {
int k=sc.nextInt();
if(k==0) break;
int arr[]=new int[k];
int copy[]=new int[6];
for (int i = 0; i < k; i++) {
arr[i]=sc.nextInt();
}
go(0,arr,copy,0);
System.out.println();
}
}
public static void go(int index,int arr[],int copy[],int cnt) {
if(cnt==6) {
for (int i = 0; i < copy.length; i++) {
System.out.print(copy[i]+" ");
}
System.out.println();
return;
}
if(index>=arr.length) return;
copy[cnt]=arr[index];
go(index+1,arr,copy,cnt+1);
copy[cnt]=0;
go(index+1,arr,copy,cnt);
}
}