题目:输出9*9口诀
1 * 1 = 1
1 * 2 = 2 2 * 2 = 4
1 * 3 = 3 2 * 3 = 6
...
1 * 9 = 9 2 * 9 = 18 ...
程序分析:分行与列考虑,共9行9列,i控制行,j控制列。
public class 第十六题输出乘法口诀 { public static void main(String[] args) { /* 1 * 1 = 1 1 * 2 = 2 2 * 2 = 4 1 * 3 = 3 2 * 3 = 6 ... 1 * 9 = 9 2 * 9 = 18 ... */ for(int i = 1; i < 10; i ++) { for( int j = 1; j <= i; j++) { System.out.print(i +" * "+j+" = "+i*j + " "); } System.out.println(); } } }
原文地址:https://www.cnblogs.com/zjulanjian/p/10952648.html
时间: 2024-09-29 10:20:27