- 利用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
- 輸出結果

