0 喜歡 0 不喜歡
362 瀏覽

Please use recursive function. 請使用遞迴函數

In mathematics, the Fibonacci numbers or Fibonacci sequence are the numbers in the following integer sequence: 0,1,1,2,3,5,8,13,21,34,55,89,144

前13的斐波那契數列:0,1,1,2,3,5,8,13,21,34,55,89,144

By definition, the first two numbers in the Fibonacci sequence is 0 and 1, and each subsequent number is the sum of the previous two. In mathematical terms, the sequence Fn of Fibonacci numbers is defined by the relation  with seed values F0 = 0, F1= 1

斐波那契數由0和1開始,其後的數就由之前的兩個數相加。用數學表示 F0 = 0, F1 = 1

Write a program that asks the user to type an integer n, then display Fn on the screen.

寫一個輸入一個整數n,輸出第n個斐波那契數的程式

Example input 1:

5

Example output 1:

5

 

Example input 2:

12

Example output 2:

144

 

[考試] 最新提問 分類:Final Exam |
ID: 43462 - 從幾時開始: 2018-01-20 09:00 - 到幾時結束: 無限制
| 362 瀏覽

6 個回答

0 喜歡 0 不喜歡
內容已隱藏
#include * * *** *

int fib(int);

int main(){
* * * * * * * ******* num;

*** ** * * ** * ** **** *** * * ** * * * **

* ** * * **** ** * ** * *** * *** *** fib(num));

* ** ** 0;
*** * * **

int fib(int n){

******** * * *** * * * num[n];
*** ** * * **** * ****** **
* *** * * * ** ** *** ** * * *

******** * * ** * * i;
* ** * * ** ** ******** = 2;i<=n;i++)
* ** * * *** * * * ** ** ***** * * * * * *

** * ******* ** * num[n];
}
最新回答 用戶: (-74 分)
0 0
Case 0: Correct output
Case 1: Correct output
Case 2: Correct output
Case 3: Correct output
0 喜歡 0 不喜歡
內容已隱藏
* * * ** * ****
int main (){
int * ****
* ** * ** **** input: * ***
*** ** ** * * **** ***
* ***
** * *
* * *
* ******* ** *
** * * ** *

return 0;
}
最新回答 用戶: (16 分)
0 0
Case 0: Wrong output
Case 1: Wrong output
Case 2: Wrong output
Case 3: Wrong output
0 喜歡 0 不喜歡
內容已隱藏
#include <stdio.h>
#include * * * * * *
#include * *** * * **

int fib(int n)
{
* ** * * * * *** (n == 0)
* * ** ** *** * * ***
** ** ******** * **** ** * ** ** **** ** 0;
** * ** ***** ***

** * *** * **** ******* if(n == 1)
** ** ** * * ****
*** * ** * *** * * ** ** ** * ** * ** ***** *** 1;
* * * * ** * ** **** ***

**** *** * *********** ** **
**** * **** *** * * * ***** ** ** * *** * * ** * fib(n-1)+fib(n-2);
}

int main()
{
* *** ****** n;
** *** fn;

** ***** * *** ***** * **** **** *

**** * * *

* * * ****** * *** * * *** *


** * * ** *** * **** * * 0;
}
最新回答 用戶: (-193 分)
0 0
Case 0: Correct output
Case 1: Correct output
Case 2: Correct output
Case 3: Correct output
0 喜歡 0 不喜歡
內容已隱藏
#include <stdio.h>
int fib(int n)
{
**** *** * * * (n==0)
* * * * * *****
* * * * ******* ** **** * * * ** * * * 1;
*** ** * * * **
* ** * *** ** * **** * * * * if (n==1)
* ***** *** * *** *
*** * * * ** * ** ** ** * ** 1;
* ** * * ** ****
** * ****** * ** if (n==2)
    {
**** * * ** * ** * * ** ** * * ** *** 1;
** * *** * ** **** ***
* * ****** *** *
    {
** **** * * * ***** * ** * * ** * * fib(n-1)+fib(n-2);
* * *** * **
}
int main()
{
* * ** ** * ** * * * * * n;
**** * *** *** * * * * ** * * * *
** * * ** ** ** * * *** ** ** * * ** * ** *
* ** * * * * * * ** 0;
}
最新回答 用戶: (-229 分)
0 0
Case 0: Correct output
Case 1: Correct output
Case 2: Correct output
Case 3: Correct output
0 喜歡 0 不喜歡
內容已隱藏
#include <stdio.h>
#include <stdlib.h>

int num,i;

int main()
{
** * *** ********* ** * ** **** ***** *** **

* * * * **** ***** ** ** * fib[num];

*** *** ** ** ******* * **** * *
* *** * ** * **

* **** *** *** * * * ** **** * *

*** ** * * * * * ** *** *** * ***** * * **** * * *** *

** *** ** ** **** ** *

* *** * * * * * * * * *** * * ***** * *****
*** **** * ** * ** *** ** * 0;
}
最新回答 用戶: (-286 分)
0 0
Case 0: Correct output
Case 1: Correct output
Case 2: Correct output
Case 3: Correct output
0 喜歡 0 不喜歡
內容已隱藏
#include<stdio.h>
int main(void)
{
* *** ******** **** * tab[100]={0};
*** * **** *** * i,num;
* * * ** ** ***** * * **** * * ** * * * **** ** ** *
* * ********* **** * ** ** **
** * ** * * * * *****
   {
* ** **** *** * ****** ** * *** ** *** * ** **** **
***** *** *** *
* * * ** *** *** ** * * ** * * ** * **** *** * **** *
* * * ** * * * ****** ** *
***** * * *** * ** *** ** *** * * * ** **
   }
******* * **** * ***
   {
* * * * ** ****** * * * ** * * * *** * *** *
*** * *** **
** *** * (num==1)
* * ** * * ** * **
* * *** * * * * ** ** ** * ** *** * * * * * *
   }
** ***** **** * * *** 0;

}
最新回答 用戶: (-168 分)
0 0
Case 0: Correct output
Case 1: Correct output
Case 2: Correct output
Case 3: Correct output
Welcome to Peer-Interaction Programming Learning System (PIPLS) LTLab, National DongHwa University
English 中文 Tiếng Việt
IP:172.71.255.11
©2016-2024

相關問題

0 喜歡 0 不喜歡
13 回答
[考試] 最新提問 1月 19, 2018 分類:Final Exam |
ID: 43463 - 從幾時開始: 2018-01-20 09:00 - 到幾時結束: 無限制
| 707 瀏覽
0 喜歡 0 不喜歡
8 回答
[考試] 最新提問 1月 19, 2018 分類:Final Exam |
ID: 43461 - 從幾時開始: 2018-01-20 09:00 - 到幾時結束: 無限制
| 426 瀏覽
0 喜歡 0 不喜歡
4 回答
[考試] 最新提問 1月 19, 2018 分類:Final Exam |
ID: 43460 - 從幾時開始: 2018-01-20 09:00 - 到幾時結束: 無限制
| 448 瀏覽
0 喜歡 0 不喜歡
12 回答
[考試] 最新提問 1月 19, 2018 分類:Final Exam |
ID: 43459 - 從幾時開始: 2018-01-20 09:00 - 到幾時結束: 無限制
| 810 瀏覽
2 喜歡 0 不喜歡
31 回答
[考試] 最新提問 1月 16, 2018 分類:Final Exam |
ID: 42301 - 從幾時開始: 2018-01-17 14:00 - 到幾時結束: 無限制
| 1.8k 瀏覽
12,783 問題
183,443 回答
172,219 留言
4,824 用戶