1 package com.xl.struct;
2
3 public class ForDemo04 {
4 public static void main(String[] args) {
5 //1.我们先打印第一列,这个大家应该都会
6 //2.我们把固定的1再用一个循环包起来
7 //3.去掉重复项, i<=j
8 //4.调整样式
9 for (int j = 1; j <= 9; j++) {
10 for (int i = 1; i <= j; i++) {
11 System.out.print(j+"*"+i+"="+(j*i)+"\t");
12
13 }
14 System.out.println();
15
16 }
17
18
19 }
20 }
1 package com.xl.exercise;
2
3 public class WhileForDemo04 {
4 public static void main(String[] args) {
5 int i,j;
6 j=1;
7 while (j<=9){
8 i=1;
9 while (i<=j) {
10 System.out.print(i + "*" + j + "=" + i * j + "\t");
11 i++;
12 }
13 j++;
14 System.out.println("");
15 }
16 }
17
18 }