0 like 0 dislike
3.8k views

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

 

[Exercise] Coding (C) - asked in Chapter 9: Functions by (5.2k points)
ID: 34912 - Available when: 2017-12-14 18:00 - Due to: Unlimited

edited by | 3.8k views

46 Answers

0 like 0 dislike
Hidden content!
#include <stdio.h>

int main()
{
* * * *** *** **** * * * * array[i];

** * ** * *** * ** j = 0;
*** * * *** ** ***
* ** ***** *** **** * *** * * &i);
** ** * * *** **** * **
*** ** * * ** ** ** * ** = 0;
* *** *** * ** **
* * ** ** * ** ** * ** * = 1;
* * ** ******** *** *
** * ******* * ** **** * = 2; j <= i; j++)
* **** *** ** ** * * * *
**** ** *** * **** ** **** * * ***** **** ** * * * = array[j - 1] + array[j -2];
* ** * * ** * * ** * *
* * *** *** * * ** **
***** * * * ** ** ** * * * * *** array[i]);
}
answered by (-285 points)
0 0
prog.c: In function 'main':
prog.c:5:17: error: 'i' undeclared (first use in this function)
       int array[i];
                 ^
prog.c:5:17: note: each undeclared identifier is reported only once for each function it appears in
0 like 0 dislike
Hidden content!
#include <stdio.h>
#include <stdlib.h>

int fibonacci[999999];
int number,i;

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

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

*** ** * ***** ** * * **** ** **** * **
* ** ** * * * * * ** 0;
}
answered by (-286 points)
0 0
Case 0: Correct output
Case 1: Correct output
Case 2: Correct output
Case 3: Correct output
0 like 0 dislike
Hidden content!
#include <stdio.h>
#include <stdlib.h>

int fibonacci[];
int number,i;

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

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

* ***** * ** ****** ******* * * * * * * ** *
*** * * * * **** ** **** 0;
}
answered by (-286 points)
0 0
prog.c:4:5: warning: array 'fibonacci' assumed to have one element
 int fibonacci[];
     ^~~~~~~~~
0 like 0 dislike
Hidden content!
#include <stdio.h>
#include * *** * **** **

int main()
{
* * * * * * * * *** ** N,i;
** ** ***** *** ** * ** * *** * ** * ** * *
*** ** * * * * * ** ***** a[N];
** * * * * *** * * ** = 0;
* ** * *** * * **** ** *** = 1;
* ******* ** * * * = 2;i <= N;i++)
* *** ** *** * * * **
***** * ** *** *** * *** ** *** * ** ** * = a[i-1] + a[i-2];
*** *** **** ******
* * ** ** ** * * * * *** ** ** *

** * *** * * ** ***** * * 0;
}
answered by (-255 points)
0 0
Case 0: Correct output
Case 1: Correct output
Case 2: Correct output
Case 3: Correct output
0 like 0 dislike
Hidden content!
#include <stdio.h>
int main()
{
**** * * * ****** ** i,n;
* * ** ** * * * * * * ****** array[40];
* * ** ** ** *********** * ** * ** * * *** *
* * * **** ***** * * * *
* * ** * **** ** *** *** * **
* * * * ****** ** *** ****** * n<=i; n++)
* * * ** * ** * * ****
****** *** *** * ** *** * ** ** ***** * * ** * * *
    }
* * * * ** * * **** ** * * * ** * *
** * * *** * * *** 0;
}
answered by (-281 points)
0 0
Case 0: Correct output
Case 1: Correct output
Case 2: Correct output
Case 3: Correct output
0 like 0 dislike
Hidden content!
#include<stdio.h>

int main(){

* * * **** * *** * a[100]={'\0'};
* * * ****** * *** i,b,c,d;


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


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

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


** ** ** * * ** *


printf("%d",a[b]);

}
answered by (-301 points)
0 0
Case 0: Correct output
Case 1: Correct output
Case 2: Correct output
Case 3: Correct output
0 like 0 dislike
Hidden content!
* * ** * ***
* ** N 100
int main (void)
{

*** ** *** arr[N];
*** ****

* *** ***** * * * ***** ****
** *** = 0;
****** *** = 1;

*** * * * * * *** {
* *** ** ** * ** = * * + * *
****** *

** * **** * * * ** *
* *** ** * * 0;
}
answered by (-167 points)
0 0
Case 0: Correct output
Case 1: Correct output
Case 2: Correct output
Case 3: Correct output
0 like 0 dislike
Hidden content!
#include<stdio.h>
int main()
{
* * *** ** ** ** *** *** a[999],i,n;
* ** * * * **** * * * * * ** ** * *** * *
* * ** * ** * * * ** * **
* ** ** * * * * *
* ** * **** ***** ** *** *** ****** *
* * ***** ** * ** *
****** * ** *** ***** * * * *** * * *
    }
* *** * *** * ** * ** * * * *** * *
}
answered by (-127 points)
edited by
0 0
Case 0: Correct output
Case 1: Correct output
Case 2: Correct output
Case 3: Correct output
0 0
Case 0: Correct output
Case 1: Correct output
Case 2: Correct output
Case 3: Correct output
0 like 0 dislike
Hidden content!
#include<stdio.h>
int main()
{
**** * * * * ** ** * a[999],i,n;
*** * ** ** ** **** *** ****** ** *** * * * *
* ** ** * * *** ** *
* * **** * * *** ****** ** * **
* *** ** * ** * * ****** *** * **** * ** *
***** **** * ** * ** ** *
* **** ** * ** ** * * * * * * **** * **** **** ***** ** *
    }
*** ** * * * * ** ** * *
}
answered by (-255 points)
0 0
Case 0: Correct output
Case 1: Correct output
Case 2: Correct output
Case 3: Correct output
0 like 0 dislike
Hidden content!
** ** ***


int main(){
int * * ****
int x,i;
*** * **** * *** * ***
fp[0]=0;
fp[1] = 1;

* * **** ** * * *
{
** * *** * *** ** *** ** * * * * *
**** * ** * *** * * * **
** * ***** *** **** * * * *** ********* ** * * *
}




* * ** *** * **
}
answered by (-336 points)
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.69.7.118
©2016-2024

Related questions

0 like 0 dislike
41 answers
[Exercise] Coding (C) - asked Dec 14, 2017 in Chapter 9: Functions by semicolon (5.2k points)
ID: 37370 - Available when: 2017-12-14 18:00 - Due to: Unlimited
| 3.2k views
0 like 0 dislike
93 answers
[Exercise] Coding (C) - asked Nov 2, 2017 in Chapter 6: Loops by semicolon (5.2k points)
ID: 29830 - Available when: 2017-11-02 18:00 - Due to: Unlimited
| 6.6k views
0 like 0 dislike
55 answers
[Exercise] Coding (C) - asked Nov 29, 2017 in Chapter 8: Arrays by semicolon (5.2k points)
ID: 34968 - Available when: 2017-11-30 18:00 - Due to: Unlimited
| 5.3k views
0 like 0 dislike
56 answers
[Exercise] Coding (C) - asked Nov 29, 2017 in Chapter 8: Arrays by semicolon (5.2k points)
ID: 34913 - Available when: 2017-11-30 18:00 - Due to: Unlimited
| 4.7k views
0 like 0 dislike
47 answers
[Exercise] Coding (C) - asked Dec 7, 2017 in Chapter 9: Functions by semicolon (5.2k points)
ID: 35785 - Available when: 2017-12-07 18:00 - Due to: Unlimited
| 3.7k views
12,783 questions
183,443 answers
172,219 comments
4,824 users