用Java编写一个程序,使数字增加1,形成一个类似图案的直角三角形。模式如下:1 2 3 4 5 6 7 8 9 10

用Java编写一个程序,使数字增加1,形成一个类似图案的直角三角形。模式如下:
1
2 3
4 5 6
7 8 9 10


public class MainPrint {
    public static void main(String[] args) {
        int start = 1; //开始
        int num = 1; //每行个数
        while(start < 10){  //需要显示多大的数,更改10即可

            for(int i = 0; i < num; i++){
                System.out.print(start++ + " ");
            }
            num += 1;
            System.out.println();
        }
    }
}

觉得有用,请采纳一下哈!!!