JAVA案例:打99乘法表和打三角形

 

package com.itheima.anli;

public class Anli3 {
    public static void main(String[] args) {
        for (int i = 1; i <=9 ; i++) {
            for(int j=1;j<=i;j++){
                int x=j*i;
                System.out.print(j+"x"+i+"="+x+" ");
            }
            System.out.println();
        }
    }
}

 

package com.itheima.anli;

public class Anli4 {
    public static void main(String[] args) {
        for (int i = 1; i <=4 ; i++) {
            for (int j = 1; j <=4-i; j++) {
                System.out.print(" ");
            }
            for (int j = 1; j <=(2*i-1); j++) {
                System.out.print("*");
            }
            System.out.println();
        }
    }
}

 

posted @ 2024-03-03 20:42  小彭先森  阅读(43)  评论(0编辑  收藏  举报