2 like 0 dislike
7.7k views
請設計一程式,使用者輸入一個正整數N,程式會輸出相對應的費氏數列第N項。

sample input:

10

sample output:

55
[Exercise] Coding (C) - asked in 作業 by (18k points)
ID: 16861 - Available when: Unlimited - Due to: Unlimited
| 7.7k views
1 2
Called for Help

44 Answers

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

int fibonacci(int number)

{
* ** * ***** * * * i,num1 = 1,num2 = 1,fibon = 0;


* * * * * * ** * * *** <= 0)
* ** * * * ** * * * * *
** * ******** ** * * * ****** * * ** ** ** ** * *** * **** * input positive number!");
* * * ** * ** * * * ** * *** * ** 0;

    }
* * * *** *** if((number == 1)||(number == 2))
** * * ** ** * ** * ** *** **** ********* ** ** ** 1;
** *** * ** * * *****
* * * * ** * ** ***
* * * * * * * * * *** * **** * * = 3;i <= number ;i++)
* *** ** *** ** *** ***** * * ** * ** ****
* * * ** * * * * * * * **** * ** ** * * ** * **** **** * ** = num1 + num2;
* ** *** *** ** ** ** * *** * ***** *** *** * *** * *** * *** * = num2;
* **** * ** * ** * * * ** * * ** *** * ** * * * ** * *** * ** * *** ** ** * = fibon;
* *** *** **** * * ** ** * *** * *
***** ** *** ******
**** * * ** * * * fibon;

}





int main()

{
** * ** * *** * *** * * num,fibonNum;


** * * ******* * *** *** * * * ******** * ** **
** *** * *** * ** * = fibonacci(num);
*** * * * **** * ** * ** ***** **




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

}
answered by (-320 points)
0 like 0 dislike
Hidden content!
#include ** ** * **

#include * * * * *

#include <math.h>

int print(int a);

int main()

{
*** * * ** ** *** *** ** **** j,f;
* * ** **** **** **** * * * * * ***** * *** *
* * ** * * *** * ** * *
* * *** ** ** ** *** * *** ** * * * *

}

int print(int a)

 {
* * **** ** * * i;
**** *** * * * last1=1,last2=1;
* *** ** num;
** * * * (a==1 || a==2)
**** ***** * * * * ** * 1;
** * ** * *****
** * ****** ** **** * * *
* * * ** *** *
***** ** *** * ** * * ** * **
* * ** * * **** * ** ** * *
* * ** **** ***** * ***
* **** ** * * *
**** *** ** ** * * num;
** *** ** * ******

 }
answered by (-162 points)
0 like 0 dislike
Hidden content!
#include ** * * *

#include ** *** ** *

#include <math.h>

int print(int a);

int main()

{
* * * ***** * ** * *** ** * j,f;
** * * * ** ** **** ** ** ** ******* * * * * *
* *** ** * * ******* * * * ** *
***** * **** *** *** * * * *** * ** **

}

int print(int a)

 {
** * * * * * i;
* * * ** ** * * * last1=1,last2=1;
* * *** ** num;
******** ** ** ** ** (a==1 || a==2)
* * ** * * ** * *** ** 1;
* *** ** * * *** *
***** ** * ** ******* ** * **
*** * *** ****
***** **** *** ** *** * ** * *
**** * * * * * * ****** ****
* * * * ** ******* * ** * * *
** **** * *
* * * * ** ***** * * * num;
** ** * *** ** * *

 }
answered by (-124 points)
0 like 0 dislike
Hidden content!
** ** ** ** ****
**** ** * * * ****
* * ** * ** * *

int ** * ****

{

int i,num1 = 1,num2 = 1,fibon = 0;




* * ** 0)
*** * * *** ** * * **** ** * ** * ** input * **** *** **** **

else ** * ** *
* * * * * * **** * * * 1;

else

{
*** * ** ** ** ** * *** ** * *
* ***** ** **** ** *
* ** ** * * * * ** * ** * *** * * = num1 + num2;
* ** * * ** ** *** * **** *** = num2;
** * * * *** * * * * ***** = fibon;
* * * ******* ** ***

}

return fibon;

}

int main ( )

{

int * * *


*** * ***** *** *** *****
** ** = * * * *
** ** * * * ****

return 0;

}
answered by (-124 points)
Welcome to Peer-Interaction Programming Learning System (PIPLS) LTLab, National DongHwa University
English 中文 Tiếng Việt
IP:162.159.115.10
©2016-2026

Related questions

1 like 0 dislike
48 answers
[Exercise] Essay (Open question) - asked Nov 2, 2016 in 作業 by Shun-Po (18k points)
ID: 16865 - Available when: Unlimited - Due to: Unlimited
| 8.7k views
1 like 0 dislike
129 answers
[Exercise] Coding (C) - asked Oct 19, 2016 in 作業 by Shun-Po (18k points)
ID: 14119 - Available when: Unlimited - Due to: Unlimited
| 16.8k views
0 like 0 dislike
117 answers
[Exercise] Coding (C) - asked Oct 13, 2016 in 作業 by Shun-Po (18k points)
ID: 13581 - Available when: Unlimited - Due to: Unlimited
| 14.3k views
0 like 0 dislike
131 answers
[Exercise] Coding (C) - asked Oct 5, 2016 in 作業 by Shun-Po (18k points)
ID: 12291 - Available when: Unlimited - Due to: Unlimited
| 17k views
0 like 0 dislike
121 answers
[Exercise] Essay (Open question) - asked Sep 21, 2016 in 作業 by Shun-Po (18k points)
ID: 11340 - Available when: Unlimited - Due to: Unlimited
| 16k views
12,783 questions
183,442 answers
172,219 comments
4,824 users