![]()
作業說明(此題需附說明檔)
目標:熟悉條件式及迴圈
題目:
下圖有點類似巴斯卡 (Pascal) 三角形。寫一程式輸入一個整數N
(0 <=N<=1000),而算出三角形的第N行。
|
|
|
|
|
|
|
1 |
|
|
|
|
|
|
|
|
|
|
|
|
1 |
|
1 |
|
|
|
|
|
|
|
|
|
|
1 |
|
2 |
|
1 |
|
|
|
|
|
|
|
|
1 |
|
3 |
|
3 |
|
1 |
|
|
|
|
|
|
1 |
|
4 |
|
5 |
|
4 |
|
1 |
|
|
|
|
1 |
|
5 |
|
7 |
|
7 |
|
5 |
|
1 |
|
|
….. |
….. |
….. |
….. |
….. |
….. |
….. |
….. |
….. |
….. |
….. |
….. |
….. |
說明:你必須仔細觀察各行資料如何產生的規則
輸出範例:
Please input an integer no greater than 1000: 3
The output is 1 2 1
Please input an integer no greater than 1000: -3
Incorrect integer entered. Enter a new integer again.
Please input an integer no greater than 1000: 6
The output is 1 5 7 7 5 1
Please input an integer no greater than 1000: 1001
Incorrect integer entered. Enter a new integer again.
Please input an integer no greater than 1000: 0
The program is terminated.
繳交期限:92年10月21日