杨辉三角的第12斜行有哪些数
来源:学生作业帮助网 编辑:作业帮 时间:2024/07/06 16:35:36
![杨辉三角的第12斜行有哪些数](/uploads/image/z/8878520-56-0.jpg?t=%E6%9D%A8%E8%BE%89%E4%B8%89%E8%A7%92%E7%9A%84%E7%AC%AC12%E6%96%9C%E8%A1%8C%E6%9C%89%E5%93%AA%E4%BA%9B%E6%95%B0)
杨辉三角的第12斜行有哪些数
杨辉三角的第12斜行有哪些数
杨辉三角的第12斜行有哪些数
1+ 11+ 22+ 44+ 88+ 176+ 176+ 88+ 44+ 22+ 11+ 1
= 684
1.11.55.165.330.162
1.11.55.165.330.162
import java.util.*;
public class Yuhang8{
public static void main(String[] args)
{
int[][] pas = new int[12][];
for(int i = 0; i < pas.length; i++)...
全部展开
1.11.55.165.330.162
import java.util.*;
public class Yuhang8{
public static void main(String[] args)
{
int[][] pas = new int[12][];
for(int i = 0; i < pas.length; i++)
{
pas[i] = new int[i + 1];
pas[i][0] = 1;
pas[i][i] = 1;
for(int j = 0; j < pas[i].length - 1; j++)
{
if(j >= 1 && i > 1)
{
pas[i][j] = pas[i - 1][j - 1] + pas[i - 1][j];
}
}
}
for(int i = 0; i < pas.length; i++)
{
for(int j = 0; j < pas.length - pas[i].length; j++)
{
System.out.print(" ");
}
for(int j = 0; j < pas[i].length; j++)
{
System.out.print(pas[i][j]);
System.out.print(" ");
}
System.out.println();
}
}
}
收起