1216 楊輝三角

2021-08-04 10:23:01 字數 552 閱讀 6179

problem description1 

1  1

1  2   1

1  3   3   1

1  4   6   4  1

1  5 10 10  5  1 

上面的圖形熟悉嗎?它就是我們中學時候學過的楊輝三角。

input

輸入資料報含多組測試資料。

每組測試資料的輸入只有乙個正整數n(1≤n≤30),表示將要輸出的楊輝三角的層數。 

輸入以0結束。

output

對應於每乙個輸入,請輸出相應層數的楊輝三角,每一層的整數之間用乙個空格隔開,每乙個楊輝三角後面加乙個空行。

example input

2

30

example output

1

1 11

1 11 2 1

hint

#include#includeint main()

for(i=0;iauthor

/*心得:

挺好的題目 */

1216 楊輝三角

1 1 1 1 2 1 1 3 3 1 1 4 6 4 1 1 5 10 10 5 1上面的圖形熟悉嗎?它就是我們中學時候學過的楊輝三角。input 輸入資料報含多組測試資料。每組測試資料的輸入只有乙個正整數n 1 n 30 表示將要輸出的楊輝三角的層數。輸入以0結束。output 對應於每乙個輸入...

python楊輝三角 楊輝三角I II

給定乙個非負整數 numrows,生成楊輝三角的前 numrows 行。在楊輝三角中,每個數是它左上方和右上方的數的和。示例 輸入 5 輸出 1 1,1 1,2,1 1,3,3,1 1,4,6,4,1 可以一行一行錯位加,當然這裡提供更簡便的方法。任取一行描述 1,2,1 如何得到 1,3,3,1 ...

Java 楊輝三角

public class yanghui 生成指定行數的楊輝三角形 param lines 楊輝三角形的行數 public void printyanghui int lines if lines 30 int line new int lines int maxlen getmaxlen line...