打印9*9乘法表
1.先打印第一列
for (int i = 1; i <= 9; i++) {
System.out.println(1+"*"+i+"="+(1*i));
}
for (int j = 1; j <=9; j++) {
for (int i = 1; i <= 9; i++) {
System.out.println(j+"*"+i+"="+(j*i));
}
}
3.去掉重复项,i<=j
for (int j = 1; j <=9; j++) {
for (int i = 1; i <= j; i++) {
System.out.println(j+"*"+i+"="+(j*i));
}
}
4.调整样式
for (int j = 1; j <=9; j++) {
for (int i = 1; i <= j; i++) {
System.out.print(j+"*"+i+"="+(j*i)+"\t");
}
System.out.println();
}