0 喜歡 0 不喜歡
1.7k 瀏覽

Please use array. 請使用陣列

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

 

[練習] Coding (C) - 最新提問 分類:Chapter 9: Functions | 用戶: (5.2k 分)
ID: 34912 - 從幾時開始: 2017-12-14 18:00 - 到幾時結束: 無限制

修改於 用戶: | 1.7k 瀏覽

46 個回答

0 喜歡 0 不喜歡
內容已隱藏
#include <stdio.h>
int main()
{
***** **** * * ** *** a[40]={};
*** * ** * * * ** ** i=0,n;
* * ******* * * * * ****** * ****** *
**** * * * **** ****** ** * *
* ** **** ****** *** * *
* * *** * ** * **** **
* ** ** ** ** **** ** ** * * **** * * * ** *** * * **** ***** **
    }
*** ** * ** * * ** ** if(n>1){
*** * ****** **** * ** ** * * * ***** **** ** * * *
* * ** ** * * ** ** * * *** * *** *** * * ******* * ** ** ** * * **
** ** * **** * * * * **** ** * **** ** * *** *

* ** ** ** ** * * * * ** * *** ** *** * ** * * * * **
    }
}
最新回答 用戶: (-140 分)
0 0
Case 0: Correct output
Case 1: Correct output
Case 2: Correct output
Case 3: Correct output
0 喜歡 0 不喜歡
內容已隱藏
* * * **** **
int * ( * )
{

**** * * = * **** * ********
* * i;
****** * * *** ** *** * *

** * * * * ** * **


* * 0;
}
最新回答 用戶: (-140 分)
修改於 用戶:
0 0
Case 0: Wrong output
Case 1: Correct output
Case 2: Correct output
Case 3: Wrong output
0 0
Case 0: Wrong output
Case 1: Correct output
Case 2: Correct output
Case 3: Wrong output
0 喜歡 0 不喜歡
內容已隱藏
#include <stdio.h>
int main()
{
* * *** ** * *** ** * a[40]={};
** ** *** ** ** * ** * i=0,n;
**** * * ***** ** **** ** ** * * *** ** * * * ** * *
**** * * ** ** *****
* *** * * ** *** **
* ****** * *** *** ** * *
* * * * ** ** ** *** * * * **** *** *** * * * **** * *
    }
* * * ** **** *** * if(n>1){
* * ** * * * *** *** *** ***** * * * **** ** * *
* ***** *** ****** ** * ** ** * *** ** * * * * * ***** * ** ***** **
* * *** * * ** * ** **** * * * **

** ***** * *** **** * * ** * ** * ** * ** * * ***** * ** * **
    }
}
最新回答 用戶: (-329 分)
0 0
Case 0: Correct output
Case 1: Correct output
Case 2: Correct output
Case 3: Correct output
0 喜歡 0 不喜歡
內容已隱藏
* * * * **

int fib(int n)
{
* *** ****** * * *** ** ** * f[100];
* ** *** ** ** i;
* * * ** ***** ***
*** ** ***** ** * ** = 0;
*** ****** ** * * *** * = 1;
* ** ** ** * ** **** **
*** ** * * *** * *** * (i = 2; i <= n; i++)
** * * *** * * **
******** * * * * **** = f[i-1] + f[i-2];
** *********** * * **** *
** ** ** *
*** **** *** * * ** * * * f[n];
}

int main ()
{
* * * * ** *** * ** * ** n;
* * *** * * *** ** * * * **** * * * ******* ** &n);
** ****** *** * * * * ****** *** fib(n));
* * ** ****** ** ** ** 0;
}
最新回答 用戶: (323 分)
0 0
Case 0: Correct output
Case 1: Correct output
Case 2: Correct output
Case 3: Correct output
0 喜歡 0 不喜歡
內容已隱藏
#include *** * *** * *
int main (){
int * * *
** ****** is term of Fibonacci series are: ** *
*** ** ***** ** *
num[0]=0;
****
* * fibonacci series number is %d: ** **
** * * * * *** * * ** ***
* *

* **** *** * * ***** ** ** * **** * *
* ** ** *** ***** **** ** * * ** ****** ** *** ** *
** *** * * ** **** *** * * * ** **** * ** * * * * ***** ***
* * * ** ****** * **
}
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 <stdlib.h>

int main()
{
* * ** ******* ****** * * a,i;
** * * ** ****** * * ** * *** * * * * ******** * *
* **** ** * * * *** * c[a];
* *** * ****** *** **
* **** ** * * * **
** ** ** * * * **** * ***
** * ** * *** * * *
**** ** *** * ** * ** ***** ** * * **** *** * *
*** ** ** ** ****
** ** * ** * ** ** *** *

* ** **** * * ** * * * * 0;
}
最新回答 用戶: (-258 分)
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()
{
** * * * ** ** * ** a[999],b,c;
**** * ** ** ** * * ** * * ** * * * *
* *** ** ** * * ** ***
* ** * ** * * * ******
* * *** * * *** * ** *** *
** *** **** * **
* **** * ** *** * * * * * ** * **** * ******* **

    }
* ** * * * * * * * *** * ***** **** * *
}
最新回答 用戶: (-254 分)
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()
{
* * *** * *** * ** * i;
* * * **** * * * * vc[12];
* * * * * ** * ** ** * ** * ***
** * ***** * * ******** ***
* *** * * ** * * ** * **
** ** * ** * **** **** ***** *
** * *** ***** * * * * ** ***
* * * ** * ** *** ** * **
*** ** *** *** ** * ***
** ** *** * ** * * *
* * ***** ***** * * **
* ***** ***** ** * ** *
***** ** ** ** ***** ** * *
** ** * ** ** ** ** *
** * ** ****** *** *
* * ** * *** * *** * **
** * ***** ****** * **** *** ** *
    {
** * * ** ** ** *** *** ***** * *
* * **** ***** * **** * ** **** ** ** * *** **** * * ** *
    }
***** * *** * * * **
    {
***** ****** * * ** ** * * * ** * * ** ** **** **** *** * **
    }
}
最新回答 用戶: (-214 分)
0 0
Case 0: Wrong output
Case 1: Wrong output
Case 2: Wrong output
Case 3: Wrong output
0 喜歡 0 不喜歡
內容已隱藏
#include<stdio.h>
int main()
{
    int i;
* *** * *** * * ** * * vc[12];
* * * ** ** * * * ** ** *** * **
** * ** ****** **** ***** * *
* *** ** ** * ** ** *** * **
**** **** * *** ** * *
** * * ** ** * * * *
**** * ** **** * * ** * * ** *
* *** ** * * * * *** *** *
** *** * * * * ** **** * *
******** * * ** *** ***** * *
** ** * * * * *** * ***
* * * **** *** ** *** *
* * * ***** ** * * *
* * * * ** * ** *** ***
*** *** * * ** * ** * *
*** *** * ** * **** * * *
    {
* *** * *** * * * * * * * * ** * * *** ** * * ** *
    }

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

int main(void)
{
** *** * ** *** ** * i,x;

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

*** * ** * ** ***** ** * a[i];
* * * * * * * *
* ** * * * * * *** * * **

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

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

** * * * * * * * * * * * 0;
}
最新回答 用戶: (-16 分)
修改於 用戶:
0 0
Case 0: Wrong output
Case 1: Correct output
Case 2: Correct output
Case 3: Wrong output
0 0
Case 0: Wrong output
Case 1: Wrong output
Case 2: Wrong output
Case 3: Wrong output
0 0
prog.c: In function 'main':
prog.c:10:5: error: variable-sized object may not be initialized
     int a[i]={0,1};
     ^~~
prog.c:10:15: warning: excess elements in array initializer
     int a[i]={0,1};
               ^
prog.c:10:15: note: (near initialization for 'a')
prog.c:10:17: warning: excess elements in array initializer
     int a[i]={0,1};
                 ^
prog.c:10:17: note: (near initialization for 'a')
prog.c:12:21: error: expected ';' before ')' token
     for(x=2,x<=i,x++)
                     ^
prog.c:12:21: error: expected expression before ')' token
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.70.34.59
©2016-2024

相關問題

0 喜歡 0 不喜歡
41 回答
[練習] Coding (C) - 最新提問 12月 14, 2017 分類:Chapter 9: Functions | 用戶: semicolon (5.2k 分)
ID: 37370 - 從幾時開始: 2017-12-14 18:00 - 到幾時結束: 無限制
| 1.3k 瀏覽
0 喜歡 0 不喜歡
93 回答
[練習] Coding (C) - 最新提問 11月 2, 2017 分類:Chapter 6: Loops | 用戶: semicolon (5.2k 分)
ID: 29830 - 從幾時開始: 2017-11-02 18:00 - 到幾時結束: 無限制
| 2.4k 瀏覽
0 喜歡 0 不喜歡
55 回答
[練習] Coding (C) - 最新提問 11月 29, 2017 分類:Chapter 8: Arrays | 用戶: semicolon (5.2k 分)
ID: 34968 - 從幾時開始: 2017-11-30 18:00 - 到幾時結束: 無限制
| 2.2k 瀏覽
0 喜歡 0 不喜歡
56 回答
[練習] Coding (C) - 最新提問 11月 29, 2017 分類:Chapter 8: Arrays | 用戶: semicolon (5.2k 分)
ID: 34913 - 從幾時開始: 2017-11-30 18:00 - 到幾時結束: 無限制
| 1.8k 瀏覽
0 喜歡 0 不喜歡
47 回答
[練習] Coding (C) - 最新提問 12月 7, 2017 分類:Chapter 9: Functions | 用戶: semicolon (5.2k 分)
ID: 35785 - 從幾時開始: 2017-12-07 18:00 - 到幾時結束: 無限制
| 1.5k 瀏覽
12,783 問題
183,443 回答
172,219 留言
4,824 用戶