java九九乘法表

来源:互联网 发布:windows黑客大曝光 编辑:程序博客网 时间:2024/05/22 14:54
这是第一种输出
 2 
 3 public class MultiplicationTable 
 4 {
 5         public static void main(String[] args)
 6         {
 7                 for(int i = 1; i <= 9; i++)
 8                 {
 9                         for(int j = 1; j <= i; j++)
10                                 System.out.print(j + "*" + i + "=" + j * i + "\t");
11                         System.out.println();
12                 }
13         }

14 }


第二种输出

 2 
 3 public class MultiplicationTable2 
 4 {
 5         public static void main(String[] args)
 6         {
 7                 for(int i = 9; i >= 1; i--)
 8                 {
 9                         for(int j = i; j >= 1; j--)
10                                 System.out.print(j + "*" + i + "=" + j * i + "\t");
11                         
12                         System.out.println();
13         
14                         for(int k = 10; k - i > 0; k--)
15                                 System.out.print("\t");
16                 }
17         }
18 }

原创粉丝点击