我正在尝试使用 11 的幂来生成帕斯卡的三角形,但它只能工作到 4 并且在 4 之后需要修改代码以实现三角形的进一步部分。任何答案的线索(如果可能通过这种方法)表示赞赏。class Solution { public List<List<Integer>> generate(int numRows) { List<List<Integer>> a = new ArrayList<List<Integer>>(); for (int i = 0; i < numRows; i++) { List<Integer> b = new ArrayList<Integer>(i); int c = (int) (Math.pow(11, i)); while (c > 0) { int d = c % 10; b.add(d); c = c / 10; } a.add(b); } return a; }}
添加回答
举报
0/150
提交
取消