import java.util.Scanner;
class BinomiaDemo1
{
public static void main(String[] args)
{
Scanner sc =new Scanner(System.in);
System.out.println("请输入一个整数");
int n =sc.nextInt();
int [][] arra=new int [n][n];
binomialArray(arra);
}
public static void binomialArray(int [][] arra)
{
for (int x=0;x<arra.length;x++)
{
arra[x][0]=1;
arra[x][x]=1;
}
for (int x=2;x<arra.length;x++)
{
for (int y=1;y<=x;y++)
{
arra[x][y]=arra[x-1][y-1]+arra[x-1][y];
}
}
for (int x=0;x<arra.length;x++)
{
for (int y=0;y<=x;y++)
{
System.out.print(arra[x][y]+"\t");
}
System.out.println();
}
}
}
|
|