利用for循環制作簡單的99乘法表


  • 利用for循環制作簡單的99乘法表
public class chengfabiao {
   public static void main(String[] args) {
       for(int a = 1;a <= 9;a++)
       {
           for(int b = 1; b <= a;b++)
           {   int res = a * b;
               System.out.print("["+a+"x"+b+"="+res+"]"); } System.out.print("\n"); 
      }
    }
}

//思路
//利用for循環,分別(左邊的數字)row,
(右邊的數字)col,
//在滿足col<=row<=9的情況下,分別自增,相乘得到每一行的結果res,然后在大循環中輸出row*col=res
  • 輸出結果

 


免責聲明!

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



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