请问各位友友这题怎么解

img

用双重for循环,外循环表示输出的行数,内循环表示每行输出的列数

步骤
第一步:输出乘法表的大体格式

/**
 * @Author ChenJiahao(程序员五条)
 * @Date 2021/9/3 21:38
 */
public class Main {
    public static void main(String[] args) {
        for (int i = 1; i <= 9; i++) {
            for (int j = 1; j <= i; j++) {
                System.out.print("1");
            }
            System.out.println();
        }
    }
}

第二步:调整乘法表的输出样式

/**
 * @Author ChenJiahao(程序员五条)
 * @Date 2021/9/3 21:38
 */
public class Main {
    public static void main(String[] args) {
        for (int i = 1; i <= 9; i++) {
            for (int j = 1; j <= i; j++) {
                System.out.print(j + " * " + i + " = | ");
            }
            System.out.println();
        }
    }
}

第三步:通过两个循环的变量值进行结果计算

/**
 * @Author ChenJiahao(程序员五条)
 * @Date 2021/9/3 21:38
 */
public class Main {
    public static void main(String[] args) {
        for (int i = 1; i <= 9; i++) {
            for (int j = 1; j <= i; j++) {
                System.out.print(j + " * " + i + " = " + (i * j) + " | ");
            }
            System.out.println();
        }
    }
}