java打印一下九九乘法表


 1 public class Multiplication {
 2 
 3     public static void main(String[] args) {
 4         printTable();
 5     }
 6 
 7     // 打印九九乘法表
 8     public static void printTable() {
 9         // 外層循環控制縱向打印多少次,從1到9
10         for (int i = 1; i <= 9; i++) {
11             // 內層循環控制橫向打印多少次,從1到i
12             for (int j = 1; j <= i; j++) {
13                 System.out.print(j + "x" + i + "=" + (i * j) + "\t");
14             }
15             System.out.println();
16         }
17     }// printTable
18 
19 }

我們來看下效果(上圖):

感覺還是不錯的


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM