2 like 0 dislike
5.3k 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
| 5.3k views
1 2
Called for Help

44 Answers

0 like 0 dislike
Hidden content!
*** * ** ****
*** ** * ***



main()



{

  int x, i,n1=1,n2=1, n=0;
* * * * **** ** * ** ** * &x);
** * ** ** * | x==2)
** ** * * ****** ** *** *** * ** * *

  else if(x==3)
**** * * * * * * * *** * ** * *******

  else
* * ** * * *** * * * * ** * *** **
* ** **** *** * ***
*** *** *** ** *** * * * * *** * ****** *
** ****** * *** ** * ** * * * * ** *** *
* * * * * *** * * ** **


** ** ** **** * ** **
****** * * **** **** ******* * ** ** * * * * n);

}
answered by (-34 points)
0 like 0 dislike
Hidden content!
#include <stdio.h>

#include <stdlib.h>

#include <math.h>

int fibonacci(int number)

{
* * ** * **** ** ***** * i,num1=1,num2=1,fibon=0;
**** *** ** ** * * *** ** * * ***
* ** ** *** * * * *** ** * input positive number!");
*** * * * * * ** ** ** 0;}
* *** * * *** * * if ((number==1)||(number==2))
*** **** * * *** * * 1;
* ** **** ** * * ** ** * * if ((number==1)||(number==2))
******* ****** * * ** 1;
**** * * *** * ****** * **
* **** **** *** *** * * * *** * * * **
** * * ***** ****** *
* * ** ** ** * ** ***** * ** * * ****** *** * **
** ** * **** *** * * ** * ** * * ** *******
*** * * **** ** * ** * * ** * ***** **** **
* ** ** *** *** * * ****
* ** ***** **** * * fibon;

}




* * ** ** *** ** ** * * ** main()
** * * * ** * * *** * **
* *** * *** **** ** * * * * * ** ** *** * * num,fibonNum;
** * * ** * ** * * * **** * ** * ** * * *** ** * * ***** *****
* *** * * * * * * ****** * **** * *** ** ** * ******** ****
* * ***** **** *** ** *** ** ** * * * * * ***** ** ** ** * *
**** *** * ** * ** * * * * * *** ** *** * ** **
* * * ** * * *** ** ** * ***** * * ** * ** 0;

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



int fib(int number)

{





int a, b = 1, c = 1, f =0;


* **** ** * ** (number <= 0)
* ** ** *** *********** * * * **


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



return 0;
* ** ** * *** * * * ***
* **** ** **** * *** * *** * if (( number == 1)||( number == 2))



return 1;


** * * * * * * *** ** ** * * ***** **
* ** ******* * * ** ** * * * * * ** *
* *** ** * * * * * * * * * * (a = 3; a <= number; a++)
* * *** ** * ** * ** *** *** *




* * ** ** ** * ** ****** * * = b + c;
* * * * * * * * * ** ** * = c;
* ** * * * *** * * * ** ** *** * = f;


* * * *** ** *** ** *** * * **
***** ***** * * * ** *
* * * **** * * * *** *** * f;

}



int main()

{

int num, fibon;


** ** *** * ****** ** * **** ***** * *** **
* * * ***** * * = fib(num);
* ** * * * *** * ** * ** * *** ** fibon);


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



return 0;



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

#include * * *

#include * * * ** ***



int *** ** (int number)

{
** * ******* * * * * ** * fibon, num1 = 1, num2 = 1,i;
**** * * ** ** * ******** *** 0)
*** * * *
** * * * * * ** ** * * 0;
**** * * * *** **** * **
* ** ** *** * * ** * * ** **** * ** == 1|| number == 2))
** * * * ***** *** *** 1;}
* ** ** **** **** * * **
** ** **** *** * * **
* * * ** *** * * ** * i <= number; i++)
** *** *** ** ** ***


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


* ** * ** ***** *** * fibon;

}

}



int main()



{
***** *** * num, fi;
* *** * * ***** ** ** * **
* * * * = * *** *
* ** ** * * *** **** ** ** fi);
* * * * 0;

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

#include ** **** **

#include * * ** *



int f(int number)

{
*** ** ** ** *** * * i, fsum[number];
* * ** * * ** ** = 1;
** * * ** * ** * * = 1;
* * ***** ** ** * * * * **
* *** * * * * ****
**** * * ** **** * ** *** = ** ** * ** *


** *** * *** * * ** * ** *
* **** * ** ****** ** *** * * * *** ** * * * = fsum[i-1] + fsum[i-2];
** * * *** * * * * * * ** *
** ** *** * * * **** ** * * ******* fsum[number];
***** **** * ** *
* * *** ** * *
* ** ****** * *** * * * 1;

}



int main()

{
** * * ** * * * * fs, number;
* * ** * ** *** * * ** ****** &number);
** * * ** * **** * = f(number);
** * ** * ** **** * * ***** * **** fs);
* ******* * * * ** 0;

}
answered by (-52 points)
0 like 0 dislike
Hidden content!
* * * * *** *** * *** ** ** ** * ** ** * ** ** printf */
** * *** * ****** * *** * * * * ** * * pow */
*** * * * ** *





long F(long n)

{
* * ** *** return 1;
* *** * * ***

}

void main()

{
* * *** n;
*** ** ** * * ** * * * **
***** * * ** * * ****** F(n));

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

#include ** ****** * *
****** * * *



int main()

{
** * ** * * ** * num = 0,sum = 0,i = 0,j = 0;
*** ** * ** * ** ** *** ** ** ** *
** ** ** * ** * a[i];


* * * * ** * = 0;j < i;j ++)
* * *** ** **
** * * * * ***** ***** **** ** ** < 2)
* **** * *** *** ** *** ** ** * = 1;


** **** * * * ** * *** ** * * **
**** **** * **** * * ** *** ***** ** = a[j-1] + a[j-2];


* * * * * **


* ** ** * ** ****** = 0;j < i;j ++)
** * ** ** ***** = i - 1)
**** *** *** ** ** * ****** * * * * ****


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

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

int *** ** * ***



{
* *** * ** int i, num ,num1 = 1, num2 = 1, ** = 0;


** * ** * **** if ** * * * 0)
* *** * **** *** ** * * * *** * * ***** ** * *** * * * * *** ** *** *
** ** *** * else if == 1) || * == 2))
**** ** ** * * 1;
* * else
** * *** ** {
*** * *** for(i = 3 ; i ** * i++)
* * ***** * ** ** {
* * * ** = num1 + num2 ;
* *** * **** **** **** = num2 ;

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

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

}



int *

{
* * *** int *** **
* **** * * * * ** * * **
**** * * * * ** = * * ****
* * ** ** ** * ************** *
** * *** **

* ** ** *** *

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

* * * * * *

}
answered by (-24 points)
0 like 0 dislike
Hidden content!
* ** * ** * ** ** * * * *** **** * * ******** printf */
** * **** * **** * ** * ** * * * ** * *** pow */
** ** * ** **** ***





long F(long n)

{
* * **** * * return 1;
* * ** * * *

}

void main()

{
*** * n;
* * * * *** *** * * * **
** * ****** * ** * ** F(n));

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

#include ***** *** ** **

#include ** * **** ***



int f(int number)

{
* * ****** * ** * i, fsum[number];
* * * * ** * ** = 1;
* * ** * **** ** **** = 1;
* * ** ** ** * * * ****
** *** * * ** *
*********** * * ** * = ** * **


*** ** * **** * ** * **
**** ** * * ** *** * ** * * **** * * * * * *** = fsum[i-1] + fsum[i-2];
** ** ********* ** ***** * * ***
*** ** ***** ** * *** * ** ** *** fsum[number];
* * * ** *
* ***** * * *** ****
* ** ** ***** ** 1;

}



int main()

{
* ** *** * ** * ** * fs, number;
*** *** * * * ** * ** ** ** ** * &number);
* * * ***** * = f(number);
********** * * * ** *** * * fs);
* ** * **** *** 0;

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

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
| 5.9k 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
| 11.7k 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
| 10.1k 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
| 11.6k 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
| 10.8k views
12,783 questions
183,442 answers
172,219 comments
4,824 users