time limit: 1000ms
memory limit: 65536kb
submit
statistic
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
230
example output
11 11
1 11 2 1
hint
author
zjgsu
#include #include int main()
, i, j, n;
while(scanf("%d", &n) && n!= 0)
for(i = 1; i < n ;i++)
}for(i = 0; i
楊輝三角與二維陣列
建立二維陣列,定義了行,沒有定義列 int arr new int 10 動態為列開闢空間 楊輝三角每行的列數和當前行號是相同的,如 第5行有5列 for int i 0 i arr.length i 賦值操作 for int i 0 i arr.length i 列印輸出 for int i 0 ...
二維陣列列印楊輝三角
讓我們用c語言來列印出高中讓我們頭疼的楊輝三角,話不多說,上 我們先建立乙個二維陣列,並初始化為0,定義兩個整形變數i,j控制行數和列數i,再定義乙個n用來接受列印的行數 int a 100 100 int i,j,n 輸入列印的行數,並控制行數在1到100行以內 do while n 0 n 10...
楊輝三角 二維陣列的應用
楊輝三角 要想寫出楊輝三角,首先得知道什麼是楊輝三角形 楊輝三角形 二項式係數在三角型中的一種幾何排列 11 1 1 2 1 1 3 3 1 1 4 6 4 1 1 5 10 10 5 1 前提 每行端點與結尾的數字為1 分析 1 鍵盤錄入乙個資料 行數 2 定義乙個二維陣列 3 遍歷二維陣列 3....