각종 회고
[TIL] 9/10 (2일차)
JH_Lucid
2021. 9. 10. 12:07
알고리즘 - 조합
for (int i = 0; i < N - 1; i++) {
for (int j = i + 1; j < N; j++) {
combX.add(i);
combY.add(j);
}
}
for (int i = 0; i < combX.size(); i++) {
System.out.print(combX.get(i) + ", " + combY.get(i));
System.out.println();
}
ArrayList(combX, combY)를 선언 후 위와 같이 조합을 생성할 수 있다.

N이 5일 경우, X는 0~3까지 & Y는 X+1부터 4까지 조합된다.