package com.wzt.www.struct;
/**
* @author WZT
* @create 2021-03-25 21:09
*/
public class ForDemo04 {
//九九乘法表
//1.先输出1*i
//2.将前面的1包起来(利用for循环)
//3.避免重复性的计算
//4.调整顺序
public static void main(String[] args) {
for (int j = 1; j <=9; j++) {
for (int i = 1; i <= j; i++) {
System.out.print(j+"*"+i+"="+(1*i)+" ");
}
System.out.println();
}
}
}
输出
1*1=1
2*1=1 2*2=2
3*1=1 3*2=2 3*3=3
4*1=1 4*2=2 4*3=3 4*4=4
5*1=1 5*2=2 5*3=3 5*4=4 5*5=5
6*1=1 6*2=2 6*3=3 6*4=4 6*5=5 6*6=6
7*1=1 7*2=2 7*3=3 7*4=4 7*5=5 7*6=6 7*7=7
8*1=1 8*2=2 8*3=3 8*4=4 8*5=5 8*6=6 8*7=7 8*8=8
9*1=1 9*2=2 9*3=3 9*4=4 9*5=5 9*6=6 9*7=7 9*8=8 9*9=9
Process finished with exit code 0