pascals-triangle

    0熱度

    3回答

    我不知道我在做什麼錯我的代碼在這裏得到一個遞歸帕卡爾的三角形在python中工作。任何幫助,懇請讚賞:) n = 5 def printPascal(n): Pascal_List = [] if n == 0: Pascal_List.append([1]) return Pascal_List if n == 1: Pasca

    -1熱度

    1回答

    我試圖參與編碼挑戰,並且我已經完成了部分代碼,但現在我需要一個函數來列出所有倍數先前輸出中的3個按降序排列。 是否有一個函數可以執行所有先前打印在三角形中的數字並將其除以3,然後打印出來的數字作爲整數從計算中出來?或者是其他一些類似的任務,想出Pascal三角形中所有3倍到50行的倍數? def generate_pascals_triangle(rows): triangle = [[

    0熱度

    1回答

    import java.util.*; public class PascalFinal { public static void main() { Scanner f = new Scanner(System.in); System.out.print("How many rows of Pascal's triangle do you want to print:

    0熱度

    1回答

    我想最大總和三角形(金字塔),但非質數必須是 收集 這是我的代碼: private static int[][] arrlist; private static ArrayList list = new ArrayList(); public static void main(String[] args) throws Exception { int[][] data =

    2熱度

    1回答

    我發現一些代碼來獲得帕斯卡三角,而無需使用數組或nCr的在Java中,如下: int maxRows = 6; int r, num; for (int i = 0; i <= maxRows; i++) { num = 1; r = i + 1; //pre-spacing for (int j = maxRows - i; j > 0; j--)

    0熱度

    2回答

    在下面的代碼: def pascal_row(row): if row == 0: return [1] previous_row = pascal_row(row - 1) pairs = zip(previous_row[:-1], previous_row[1:]) return [1] + map(sum, pairs) + [1]

    -1熱度

    1回答

    我需要編寫一個函數來查找弗洛伊德三角形中的相鄰塊。 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 什麼是要找到一個給定值的相鄰塊(上,

    2熱度

    2回答

    您好我正在Java中製作迭代帕斯卡三角形。到目前爲止,一切都很好,直到行數超過13爲止。輸出變得有缺陷。我一定在這裏做錯了,請幫忙。 IterativePascal: public class IterativePascal extends ErrorPascal implements Pascal { private int n; IterativePascal(int n)

    1熱度

    2回答

    我所做的楊輝三角的實現,但事情是錯了,因爲當col match { case row => ...}不正確的山坳與行相匹配: def main(args: Array[String]) { println("Pascal's Triangle") for (row <- 0 to 10) { for (col <- 0 to row) { val res: Int = pa

    1熱度

    2回答

    所以,我由於某種原因,代碼是給我的錯誤: TypeError: Can't convert 'int' object to str implicitly 它與線做: answer = answer + combination(row, column) + "\t" 這裏是我的代碼: def combination(n, k): if k == 0 or k == n: