-
0320 중복순열 구하기_DFSTIL 2025. 3. 20. 23:32
// 중복 순열 구하기 문제 package org.example.infrenJavaCodingTest; import java.util.Scanner; public class chap9_4 { static int[] pm; static int n , m; public void DFS(int L){ if(L==m){ for(int x : pm) System.out.print(x+" "); System.out.println(); } else{ // n 만큼 for(int i=1; i<=n; i++) pm[L] = i; DFS(L+1); } } } public static void main(String[] args) { // 중복순열 -> 호출이 n 번 chap9_4 T = new chap9_4(); Scanner kb = new Scanner(System.in); n=kb.nextInt(); m=kb.nextInt(); pm=new int[m]; T.DFS(0); } }