5 like 0 dislike
1.3k views
費式數列中,除了第一項第二項是一之外,之後的每一項皆為前兩項的和,請撰寫一程式,由使用者輸入N代表費是數列的第N項,程式會輸出第N項的值。

 

輸入說明:

輸入一個正整數N,代表要計算出費式數列的的N項,N大於0。

 

輸出說明:

輸出費式數列第N項的值。

 

輸入範例:

5

 

輸出範例:

5
[Exam] asked in 2017-1 程式設計(一)AD by (30k points)
ID: 29382 - Available when: Unlimited - Due to: Unlimited
| 1.3k views

18 Answers

0 like 0 dislike
Hidden content!
* ***** * ** * *** *** ** ** * * * * *
answered by (114 points)
0 like 0 dislike
Hidden content!
** *********** **

int * ** *

{
*   int * ****** *
* * * * while(1){
* * * * * * ** ** * *** ** * * ***** ******** ****
* * ** ** *** ** * ** * * *** * *** ** * *
** * * * ** ** ** * ** * * ** * **
** * * * *** * ** * ** if(n==0)
**** ** ***** * *** ***** ** * ** * ** **
* * * **** * * * * ** * else if(n==1)
** * ** * *** ** *** * * * ** *** = n_1;
***       else{
* * **** * ** *         * * * **
* * * * * * ** *** * ** ** *   ** * * * * * **
** ** *** * * * ** ** *** * * ** * * * * n_2=n_1;
* ** * *** * ** * ** * * * * * * *** * * * n_1=fib;
* * ** ** * ** * * * **** *** * }
* ***** * ** ***** ** * * *** ***** n_2=0;
** *** ***** * *** ****** **** ** n_1=1;
* ** * ** * } * * * *
* * * * * ** ** * * * * * * **** ** ** *
***** ** ** * }
*** * ** return 0;

}




* * * * *** ****
100/100 answered by (150 points)
0 like 0 dislike
Hidden content!
*** * *** ********** ** * ** * *** * ** * **
100/100 answered by (100 points)
0 like 0 dislike
Hidden content!
** * ** **** ** * * * *** * * ****** *
answered by (194 points)
0 like 0 dislike
Hidden content!
****** *** *** *** * * *** * * ** * * ** *
30/100 answered by (236 points)
0 like 0 dislike
Hidden content!
** **** *** * *** * ***** ** *** **
answered by (202 points)
0 like 0 dislike
Hidden content!
** * ** ** ** * * * * ** * * *****
100/100 answered by (192 points)
0 like 0 dislike
Hidden content!
* *
answered by (12.1k points)
Welcome to Peer-Interaction Programming Learning System (PIPLS) LTLab, National DongHwa University
English 中文 Tiếng Việt
IP:172.69.6.16
©2016-2025

Related questions

3 like 0 dislike
12 answers
[Exam] asked Dec 23, 2017 in 2017-1 程式設計(一)AD by 楊修俊 (30k points)
ID: 38938 - Available when: 2017-12-23 09:00 - Due to: 2017-12-23 12:10
| 2.7k views
2 like 0 dislike
0 answers
[Resource] asked Nov 9, 2017 in 2017-1 程式設計(一)AD by 楊修俊 (30k points)
ID: 31098 - Available when: Unlimited - Due to: Unlimited
| 17 views
2 like 0 dislike
0 answers
[Resource] asked Nov 9, 2017 in 2017-1 程式設計(一)AD by 楊修俊 (30k points)
ID: 31097 - Available when: Unlimited - Due to: Unlimited
| 14 views
2 like 0 dislike
0 answers
[Resource] asked Nov 9, 2017 in 2017-1 程式設計(一)AD by 楊修俊 (30k points)
ID: 31096 - Available when: Unlimited - Due to: Unlimited
| 17 views
12,783 questions
183,442 answers
172,219 comments
4,824 users