Java教程

Java打印图案17

1
1 2
1 2 3
1 2 3 4
1 2 3 4 5

程序:

public class pattern4
{
    public static void main(String[] args)
    {
        int n = 5;
        for(int i = 0 ; i <= n ; i++)
        {
            for(int j = 0 ; j < i ; j++)
        {
                System.out.print(j+1);
            }
            System.out.println("");
        }
    }
}
输出:
1
1 2
1 2 3
1 2 3 4
1 2 3 4 5
昵称: 邮箱:
Copyright © 2022 立地货 All Rights Reserved.
备案号:京ICP备14037608号-4