杨辉三角---等腰三角形

public class test
{
    public static void main(String[] agrs)
    {
        int row = 6;
        int xy[][] = new int[row][row];
       
        for (int i = 0; i < row; i++)
        {
            for (int j = 0; j <= i; j++)
            {
                if (j == 0 || i == j)
                {
                    xy[i][j] = 1;
                }
                else
                {
                    xy[i][j] = xy[i - 1][j - 1] + xy[i - 1][j];
                }
            }
           
        }
       
        for (int i = 0; i < row; i++)
        {
            for (int j = 0; j < row - i; j++)
            {
                System.out.print(" ");
            }
            for (int j = 0; j < i + 1; j++)
            {
                System.out.print(xy[i][j] +" ");
            }
            System.out.println();
        }
    }
   
}

你可能感兴趣的:(杨辉三角)