打印乘法口诀表练习 Mul

public class Mul {

    public static void main(String[] args) {

        // 第一种方法
        for (int i = 1; i <= 9; i++) {
            for (int j = 1; j <= 9; j++) {
                if (i <= j)
                    System.out.print(i + "*" + j + "=" + (i * j) + "    ");
            }
            System.out.println();
        }

        // 第二种方法
        for (int i = 1, j = 1; i <= 9; j++) {
            System.out.print(i + "*" + j + "=" + (i * j) + "    ");
            if (j == 9) {
                j = i;
                i++;
                System.out.println();
            }
        }
    }
}

 

posted @ 2014-04-29 22:06  mycome  阅读(218)  评论(0编辑  收藏  举报