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

sample input:

10

sample output:

55
[Exercise] Coding (C) - asked in 作業 by (18k points)
ID: 16957 - Available when: Unlimited - Due to: Unlimited
| 3.6k views

26 Answers

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

#include <stdlib.h>



int printFi ()

{
* * * ** * ** * * * * i=0,
* ** ** *** * * * ** *** ** * **** * ** **** * * **
** ** *** * * ** *** * * ** * * * *
** * ** ** * * * ** * ** *** ** *
* ** * * * * ** ** * * * ** ** * ***

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

    
* * ****** *** * **** * * (n==1||n==2)
* ****** * * * ** * * * *** * * * * 1;
*** *** ** ** **
** * ** * ** *** * *** * * * * * ** **** ** * ** * {
* * ** * * * *** ** * * * ** * *** *** **** ** * * = l1 + l2;
* * * ** ***** ** ** * * * **** ** * * ** * *** **** = l2;
* * ** *** * * * ** * ** *** * * ** *** *** ** *** = sum;
* *** *** ** * *** * * * * * *** ** * ** * *

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

}



int main ()

{
* * ****** ** *** ** * *

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

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

#include <stdlib.h>

#include <math.h>



int fk(int num)

{
**** * ***** ** **** **** * * * * ** *
* * * * ** ** ***** *** * * *** ** ****** * 1;
***** * ** * ***** i,last1=1,last2=1,sum=0;
* ** ** ** ***** * * *
* * * * * ** * *** **** ************** * ** * **
* * * ** * ***** *** * * ** *** **** *** **** **
***** *** * * * * * ****** * ** ***
* ** *** ** ********* *** ****
** *** *** * * * ** * ** *** ** **** ***

}



int main()

{
* *** * *** * * ** * ** * num=0;
*** *** *** * * ** * *** * * **** *
**** ** ******* *** *


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

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

#include<stdlib.h>



int fi(int n)



{
** * ** * * ** * * * * x,y=1,z=1,t=0;

    
* * * **** * ***** * * *
*** * **** * ** * ***** *****
**** * * *** * ** * * ***** **** 1;
**** * * * * * * *
****** * * ** *** * * *
* * ** ** * * * * * ***
* ** * ** * ** *** ** *
** * * ** * **** ** ** * * ** * * *** * ** * **** **
* * ** ** ** * * *** * **** ** ** **** ** * ** ** *
* * ********** * *** * * * * *** * *** * *
**** *** ** **** * * **** ** * *** * * * * ***** * * * * ** * * ** ** *** * * ** * *** * *** * *** *** * * * * *** ** ** * * * * ** * *
* * * * ** ***** * * * ***** ** * ** *** ** ** * *** * * ** ***** * ** ** ** **** ** * *** ** * *** ** * * *** * **** ** * * * * * **
** *** ***** ** ** * ** * ****** ** ** * * ** * * *** ** ** * *** * ** ** * **** * * ** * *** * **** * * **** ** *** ** *** * **
*** * ** ** * ***** * **** ** * ** ** * * *** * * ** * ***** ** **** ** **** * *** * *** * *** **** * * * *** * * * ** ** * * * * * * * ** ****
* ** *** * * * **** * * **** ** **** * * *** ** * * **** ** ** * * ** * * * ** * * * * ******* * *** * *** * *** * ** * * * ** **
* * ** * **** ** ***** ** *** ** ** * *** ***** * ** * *** * ** * * ** **** *** * ** ** *** ** * * * *** * ** * * ** * ** * * * * * ** ***
* ** * ** * ** * ** * * * ** ** **** *******
** *** * * *** *** * * *** ** * * * *** **
** * * *** * * * *** * * t;
* ***** * ** * **** * * *
* ****** * **** * * **

}
** * ** ** * ** * ** * * * ***** **** * * * ******* * *** * * ** * * * * * * *** * ***** ** **** * * * **** * **** * * * * * * * ** * * *

     

     



int main()



{

    int i,j,k=0;

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

    



    

    k=fi(i);

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

    

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

    return 0;

    

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

#include <stdlib.h>

int main()

{
* * * **** * * * ***** *** int num;
** * * * * ***** * * *** a=1;
** ********* * * ** ** b=1;
** * * * * * ** * * k=0;
** * ***** * * *** * **** i;
* * * ** *** * * ** ** **** ** ****** ** &num);
******* ***** ** **** * * || num==2)
****** ** * *** ** *
* * * ***** ** ** ** *** * * * * *** * * ** = 1;
** **** ** * ** **** * * ** * * ** ** * ** ** * * *

    }
* **** ** * *** ** * **

    {   
* * ** ** ** ** ** * ** * * * *** ** * i<=num; i++)
*** * * *** * * ** ** * * ****
* *** ** ** * ****** ** ** * * *** ***** * * *** = a + b;
****** ** *** * * * ** * *** * * * * ** * * * ** *** ** = b;
* ** ******** * * **** ** * * ** **** * * * ***** * = k;
* * * * * *** * **** ** * * ** *
*** * * * ** * *** **** * * * * ***** ** * ** * ***
** **** ** **** ****
* *** ** * * ** ** * ****** * **
** ** ** ** *** ** * *** * 0;

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

#include * * ** ** ***

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



int sum(int a,int b)

{
*** * ** **** * ***** **** **** ** * = 0 , i ;
* ** * **** ** * ** * ***** * i = a ; i <= b ; i++ )
** * *** * * **** ******** * * * ** ** *** ** *** += i ;
** * ** * * * ** * * ** *
**** * * * ** *** ** sum;

}



int *** * n)

{
** ** * * * * * ** *** a[n] , i ;
* *** * ***** ** * * *
** * *** *** * **** * a[0] = 1 , a[1] = 1 , i = 2 ; i < n ; i++ )
** * * *** * **** * * *** * * *** **** **** = a[i-1] + a[i-2] ;
** * ** * * ** *
** ** ** ** ** * * a[n-1];

}



int main()

{
* ** * * * * * * * * n ;
***** ** ** * ** ** * * ** ** * *** *
* *** * ** * * ** ** * * * **** *** * **
*** * * ** * * ** *** ** ** * *
* * ** ** * ** ** * 0;

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

#include * * *



int sum(int a,int b)

{
* *** **** * * * * * *** * * = 0 , i ;
* ** *** * ** * * * **** i = a ; i <= b ; i++ )
** * * ** ** * * *** * * ******* *** ** ** * ** *** += i ;
* * *** ** * * *** **
* *** ***** * * ** * ** * ** * sum;

}



int ** n)

{
* * * ** * * * ** * * * a[n] , i ;
** **** ** * ** * ** ****
** *** * ** *** *** a[0] = 1 , a[1] = 1 , i = 2 ; i < n ; i++ )
** * *** ** * ** **** * **** ** * ** * *** * = a[i-1] + a[i-2] ;
* * * **** **** * *
* * *** ** ***** ** *** a[n-1];

}



int main()

{
* ***** * * n ;
** * * ** * * * ** ** *** *** * ** *** **
* ******** * ** ** ** ** ** * * ** * * *
* * ** **** * ** * **** *** * * * ******
* ****** * ***** * *** 0;

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

Related questions

0 like 0 dislike
31 answers
[Exercise] Essay (Open question) - asked Nov 3, 2016 in 作業 by Shun-Po (18k points)
ID: 16958 - Available when: Unlimited - Due to: Unlimited
| 4k views
0 like 0 dislike
37 answers
[Exercise] Coding (C) - asked Oct 20, 2016 in 作業 by Shun-Po (18k points)
ID: 14579 - Available when: Unlimited - Due to: Unlimited
| 4.2k views
0 like 0 dislike
67 answers
[Exercise] Coding (C) - asked Oct 13, 2016 in 作業 by Shun-Po (18k points)
ID: 13427 - Available when: Unlimited - Due to: Unlimited
| 7.1k views
0 like 0 dislike
73 answers
[Exercise] Coding (C) - asked Sep 29, 2016 in 作業 by Shun-Po (18k points)
ID: 11603 - Available when: Unlimited - Due to: Unlimited
| 7.8k views
0 like 0 dislike
66 answers
[Exercise] Essay (Open question) - asked Sep 22, 2016 in 作業 by Shun-Po (18k points)
ID: 11532 - Available when: Unlimited - Due to: Unlimited
| 6.9k views
12,783 questions
183,442 answers
172,219 comments
4,824 users