我正在嘗試使用 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; }}
我正在嘗試生成列表列表以返回帕斯卡三角形
慕婉清6462132
2022-07-14 09:31:32