1 //99乘法口诀 2 public static void main(String args[]) throws Exception{ 3 int i,j,n = 9; 4 System.out.print(" * | 1 2 3 4 5 6 7 8 9 "); 5 System.out.println(); 6 System.out.print("---|----------------------------"); 7 System.out.println(); 8 for (i = 1; i <= n; i++) { 9 System.out.print(" " + i + " |"); 10 for (j = 1; j <= i; j++) { 11 int test = i*j/10; 12 if (test < 1) { 13 System.out.print(" " + i*j + " "); 14 }else if (test >= 1) { 15 System.out.print(" " + i*j); 16 } 17 } 18 System.out.println(); 19 } 20 }
预览效果