首页 > 其他 > 详细

杨辉三角

时间:2018-04-01 22:51:03      阅读:164      评论:0      收藏:0      [点我收藏+]

public class Yanghui {
public static int[][]yanghui(int n)
{
int mat[][]=new int [n][];
for(i=0;i<n;i++)
{
mat[i]=new int[n+1];
mat[i][0]=mat[i][i]=1;
for(int j=1;j<i;j++)
mat[i][j]=mat[i-1][j-1]+mat[i-1][j];
}
return mat;
}
public static void print(int mat[][])
{
for(int i=0;i<mat.length;i++)
{
for(int j=0;j<mat.length;i++)
System.out.print(""+mat[i][j]);
System.Out.println();
}
}
public static void main(String args[])
{
print(Yanghui(10));
}

}

杨辉三角

原文:https://www.cnblogs.com/MuXiao-DJT/p/8688652.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!