✔️문제
- 구구단 시작 s부터 f단까지 입력 받아 아래와 같이 출력하시오.
- 입력: 2 3
- 정답:
2 * 1 = 2 3 * 1 = 3
2 * 2 = 4 3 * 2 = 6
2 * 3 = 6 3 * 3 = 9
2 * 4 = 8 3 * 4 = 12
2 * 5 = 10 3 * 5 = 15
2 * 6 = 12 3 * 6 = 18
2 * 7 = 14 3 * 7 = 21
2 * 8 = 16 3 * 8 = 24
2 * 9 = 18 3 * 9 = 27
📍정답
package _12_gugudan;
public class Main {
public static void main(String[] args) {
int s = 2;
int f = 5;
for (int i = 1; i <= 9; i++) { // 행
for (int dan = s; dan <= f; dan++) { // 열
System.out.printf("%2d *%2d =%3d", dan, i, dan * i);
}
System.out.println();
}
}
}
'개발인생 > Altorithm' 카테고리의 다른 글
별 찍기 패턴 정리💫 (0) | 2025.03.11 |
---|---|
[알고리즘 기초 100제] 13. 별찍기 (0) | 2025.03.11 |
[알고리즘 기초 100제] 11. 숫자 개수 출력 (0) | 2025.03.11 |
[알고리즘 기초 100제] 10. 숫자 사각형(1)~(4) (1) | 2025.03.11 |
[알고리즘 기초 100제] 9. 각 자릿수 합 구하기 (2) | 2025.03.10 |