2017/07/29

每列顯示N行的九九乘法表(Java)

public class MultiplicationClass {

public static void main(String[] args) {
multiplication_table(3);
}

static void multiplication_table(int column) {
for (int i = 1; i <= 9; i += column) {
for (int j= 1; j <= 9; j++) {
for (int k = 0; ((k < column) && (i + k) <= 9); k++) {
System.out.printf("%d * %d = %d\t", (i + k), j, (i + k)*j);
}
System.out.println();
}
System.out.println();
}
}

}