입력하세요
3
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=10 3*5=15
1*6=6 2*6=12 3*6=18
1*7=7 2*7=14 3*7=21
1*8=8 2*8=16 3*8=24
1*9=9 2*9=18 3*9=27
4*1=4 5단 6단
...
..
.
7단 8단 9단
...
...
하아.. 질문하기도 힘들다 이거... 이거 풀려고 물어봤던건데 그거가지곤 안되네...
이것도 간단합니까????
힌트좀 주세여..
import java.util.Scanner;
public class test2 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.println("출력");
String str = sc.next();
int num = Integer.parseInt(str);
for (int i = 1; i <= 9; i++) {
if (num % i == 0) {
for (int j = 1; j <= 9; j++) {
for (int k = 1; k <= num; k++) {
System.out.print(k + "*" + j + "=" + (k * j) + " ");
}
System.out.println();
}
} else if (num % i != 0) {
for (int j = 1; j <= 9; j++) {
// System.out.print(j + "*" + i + "=" + (j * i) + " ");
System.out.println();
}
}
System.out.println();
}
sc.close();
}
}
// System.out.print(j + "*" + i + "=" + (j * i) + " ");
여기까지 하다가 포기하고 잘려고 하는중...
댓글 0