第一題:
請撰寫一 Java 程式,用以輸出下列的九九乘法表。【25 分】
663063a2abae2.jpg

詳解 (共 1 筆)

詳解 提供者:hchungw
public class MultiplicationTable {
    public static void main(String[] args) {
        // Loop through columns
        for (int i = 1; i <= 9; i++) {
            // Loop through rows
            for (int j = 1; j <= 9; j++) {
                // Print each product with formatted output
                System.out.printf("%d★%d=%-2d ", j, i, i * j);
            }
            // Move to the next line after each column
            System.out.println();
        }
    }
}