결과창
1*1=1 2*1=2 3*1=3
1*2=2 2*2=4 3*2=6
1*3=3 2*3=6 3*3=9
1*4=4 2*4=8 3*4=12
1*5=5 2*5=103*5=15
1*6=6 2*6=123*6=18
1*7=7 2*7=143*7=21
1*8=8 2*8=16 3*8=24
1*9=9 2*9=183*9=27
4*1=4 5*1=5 6*1=6
4*2=8 5*2=106*2=12
4*3=125*3=156*3=18
4*4=165*4=20 6*4=24
4*5=205*5=256*5=30
4*6=245*6=306*6=36
4*7=285*7=356*7=42
4*8=325*8=406*8=48
4*9=365*9=456*9=54
7*1=7 8*1=8 9*1=9
7*2=148*2=169*2=18
7*3=218*3=249*3=27
7*4=288*4=329*4=36
7*5=358*5=409*5=45
7*6=428*6=489*6=54
7*7=498*7=569*7=63
7*8=568*8=649*8=72
7*9=638*9=72 9*9=81
소스코드
------------------------------------------------------------------
import java.util.Scanner;
public class Test21 {
public static void main(String[] arg) {
for (int i = 1; i < 10; i += 3) {
for (int j = 1; j < 10; j++) {
for (int k = i; k < i + 3; k++)
System.out.printf(k + "*" + j + "=" + k * j + "\t");
System.out.println();
}
System.out.println();
}
}
}
출처: 삼성SDS멀티캠퍼스
강사: 홍승길
Email :
1. 2단부터 9단까지 세로로 구구단 출력
public static void main(String[] args) { for(int i=2; i<10; i++) { for(int j=1; j<10; j++) { System.out.println(i + "x" + j + "="+ (i*j)); } System.out.println(); } }결과화면 :
더보기
2x1=2
2x2=4
2x3=6
2x4=8
2x5=10
2x6=12
2x7=14
2x8=16
2x9=18
3x1=3
3x2=6
3x3=9
3x4=12
3x5=15
3x6=18
3x7=21
3x8=24
3x9=27
4x1=4
4x2=8
4x3=12
4x4=16
4x5=20
4x6=24
4x7=28
4x8=32
4x9=36
5x1=5
5x2=10
5x3=15
5x4=20
5x5=25
5x6=30
5x7=35
5x8=40
5x9=45
6x1=6
6x2=12
6x3=18
6x4=24
6x5=30
6x6=36
6x7=42
6x8=48
6x9=54
7x1=7
7x2=14
7x3=21
7x4=28
7x5=35
7x6=42
7x7=49
7x8=56
7x9=63
8x1=8
8x2=16
8x3=24
8x4=32
8x5=40
8x6=48
8x7=56
8x8=64
8x9=72
9x1=9
9x2=18
9x3=27
9x4=36
9x5=45
9x6=54
9x7=63
9x8=72
9x9=81
2. 2단부터 9단까지 가로로 구구단 출력
public static void main(String[] args) { for(int i=1; i<10; i++) { for(int j=2; j<10; j++) { System.out.print(j + "x" + i + "="+ (i*j) + "\t"); } System.out.println(); } }결과화면:
더보기
2x1=23x1=34x1=45x1=56x1=67x1=78x1=89x1=9
2x2=43x2=64x2=85x2=10 6x2=127x2=148x2=169x2=18
2x3=63x3=94x3=125x3=156x3=187x3=218x3=249x3=27
2x4=83x4=124x4=165x4=206x4=247x4=288x4=329x4=36
2x5=103x5=154x5=205x5=256x5=30 7x5=358x5=409x5=45
2x6=123x6=184x6=245x6=306x6=367x6=428x6=489x6=54
2x7=143x7=214x7=285x7=356x7=427x7=498x7=569x7=63
2x8=163x8=244x8=325x8=406x8=487x8=56 8x8=649x8=72
2x9=183x9=274x9=365x9=456x9=547x9=638x9=729x9=81
3. 1단부터 9단까지 3행 3열로 구구단 출력
public static void main(String[] args) { for(int i=1; i<10; i+=3) { for(int j=1; j<10; j++) { for(int k=i; k<3+i; k++) { System.out.print(k + "x" + j + "=" + k*j + "\t"); } System.out.println(); } System.out.println(); } }결과화면:
더보기
1x1=12x1=23x1=3
1x2=22x2=43x2=6
1x3=32x3=63x3=9
1x4=42x4=83x4=12
1x5=52x5=103x5=15
1x6=62x6=123x6=18
1x7=72x7=143x7=21
1x8=82x8=163x8=24
1x9=92x9=183x9=27
4x1=45x1=56x1=6
4x2=85x2=106x2=12
4x3=125x3=156x3=18
4x4=165x4=206x4=24
4x5=205x5=256x5=30
4x6=245x6=306x6=36
4x7=285x7=356x7=42
4x8=325x8=406x8=48
4x9=365x9=45 6x9=54
7x1=78x1=89x1=9
7x2=148x2=169x2=18
7x3=218x3=249x3=27
7x4=288x4=329x4=36
7x5=358x5=409x5=45
7x6=428x6=489x6=54
7x7=498x7=569x7=63
7x8=56 8x8=649x8=72
7x9=638x9=729x9=81