0 like 0 dislike
692 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
| 692 views

26 Answers

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

#include<stdlib.h>

int plus11(int num)

{
** ** * * ***** ** *** ** a,b=0;
* * **** * * * ** ** * ** ******
*** * ** * ** * * ** *** ** * **** * = b+a;
**** ** *** * *** * ******* * * ** *
* **** ** * * ** * * ** * ***** * *
**** * * ** *** * * *** *
*** ** *** ** *** * ******

int main()

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

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

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

#include<stdlib.h>



int main()

{
* ** ***** **** * * * i,n,fi,last1 = 1,last2 = 1;
* *** * *** ** * * * *
** *** ** *** * *** *** * ** ** ** ***** * * * ***
* * ** ** * * * **
*** **** ** *** * * * *** *** **** == 1||n == 2)
** * ** * ** * * ** *** * * * * * *** **
* ** *** * ** * * **
* *** * ** * **** * **** * *
* * * * *** * * * **** * = 3;i <= n;i++)
*** ***** * * * * **** * ****** + last2;   
* ** * ** ** * ** * * *** * * ***** ** = last1;
**** ** * ** *** ** * ****** * * ** **** = fi;};
* * ** *** ** ** ** * ** ******* * * ** *
* * * * * * ** ** * *** * *
***** **** * * * *** * ***** * * ** * **
** *** ** ** ** * *** *** * ** * 0;

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

#include <stdlib.h>



int sumNfiS(int num)

{
** * ** **** ** ** i, num1 = 1, num2 = 1, sum = 0;
*** * ***** ** * ((num == 1) || (num == 2))
** ** * *** * ** *
* * *** *** ** ** * **** ** * * * *** ****** ** ** * 1;
** ** *** * ** ** *** * *
** **** * ** * **
* * ***** * ****** ** *
** * ** * * * * * ** * * ** * * * * ** * (i = 3; i <= num; i++)
** * **** * ** ** **** * * ***** *** * *
* *** ** * * ** ** * ** * ***** * * * * ** * *** ** ** * ** = num1 + num2;
* **** * * * ** ** *** * * **** *** ***** * ** * **** * * * *** * ***** = num2;
**** * ** ** ** *** *** * **** * *** ***** * * ** **** * *** ** **** ***** = sum;
*** ** * ** * * * * * * * ** * ** * *
** * ** * ** ** * ** ** * * **** ******** sum;
* ** * * * * ** ***

}



int main()

{
* * * *** * * *** num, sum;
***** ** * ** ** ** * * * *** * ** * &num);
* ** ** ** *** = sumNfiS(num);
*** * *** ** * ** * ***** *** ** ** * * * sum);


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

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

#include<stdlib.h>

int main()

{
* ** * * * * * * ** * ** int num;
* ** * * * ** ** a,n,b=1,c=1;
* ** * **** * * *** * * * ** * * *
** *** ****** * * ***** *** ***

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

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

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

    }
***** * **** ** * * ** * ** *****
***** * *** * * * * 0;

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

#include <stdlib.h>



int sumNfiS(num)

{
* * ** * * **** * * ** ** i, num1 = 1, num2 = 1, sum = 0;
* ***** * * *** ****** ((num == 1) || (num == 2))
* **** * ** ** ** **
* * *** * * * * *** * **** * **** * * **** * 1;
* *** ** * **** ** *
* ***** ** **** ***
* * * **** ********** *
* * * ** ** * ** ** ** ** ** * * * *** * (i = 3; i <= num; i++)
* ***** *** * ** * ** * * * * ** ** *** **** ** ** *
*** * ***** * ***** *** * * ****** * * * * * * *** * ******** * ** * * ** = num1 + num2;
****** * * * * ** * * * ** *** * *** ****** * * * * *** ******* * * = num2;
** *** *** *** ** * ** * ** * ** ** **** **** * * **** = sum;
*** *** ** *** ** * ** * * ******** ****** **
* **** *** ****** ** * * ** ** ** * * * * **** * sum;
* ***** **** ** *** *

}



int main()

{
* * ******* * ** * *** * * num, sum;
* ** * ******* *** **** * *** ** **** &num);
** ** * * * * * * *** = sumNfiS(num);
* * ** ** * * * * * * * * * * ** sum);


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

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

#include<math.h>

int main()

{
*** * * * * * *** i,j,k=0,a=1,b=1;
**** ** **** **** ** **** *** * * ***
* * * * * * ** ******** * || i==1)
* * ** ** * * **** * * ** ** *** *
**** * **** * **

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

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

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

}
* * ** ** **** * * * *** 0;







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

#include <stdlib.h>



void Fibonacci(int x)

{
** * ** * k, num1, num2, i;
* * * * * **** **** = 1;
* * * * * ** = 1;
* * * * **** == 1 || x == 2)
* * * ** * * ** * * ** * ** ***** ** ***
*** * * * * *** **
******* *** *
*** **** * ****** ** * * * ** ** = 3;i <= x;i ++)
*** ** * * **** ** * * ** *
** * ** *** ***** * **** ** ***** * * ** * ** = num1 + num2;
** *** *** *** * * * *** * * * * * * * * * ** * = num2;
***** * **** ** * ******* * * * * * * *** * * * * * = k;
*** ** ** *** * ****** **
* * ** * ** * * * ** * * ** *** * * * k);
** * ** ** ** *



}

int main()

{
*** ** * * * * * x;
* *** * * * ** * ** ** *** * ** &x);
* * **** ****** *** ** **
** ** * * ** ** * 0;

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

#include<stdlib.h>

int fas(int N)

{
* **** * * * **** * i,sum=0;
***** * **** * * * * x=1,y=1;

* * ***** * **** ** * ** *
**** *** *** ** * ** ******* ** * * ** * *** 1;
*** * *** * * ** * *
** ***** *** * * ** * ***** ** *** *** 1;

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

    {

** ****** * ** * **** * ** ** ******* *
** * ** *** ** ** * * **** * * ***** *   
* ***** * * * ** *** * * * * ** * * * ** * **** ** *** ** = x+y;
* ** * * ** * *** * ** *** ** * ****** **** * * = y;
* ** ** ** ** * * ****** * * * ** * * *** *** * * ** = sum;
* * * * **** * * ** * * * *********
* ** ** * * *** ** ****
*** * ** ** ** *** ** * * * * * sum;

}



int main()

{
* * * * ** ** a,total=0;
* *** * * * ** * ** * ** * *** * * * * * *
* * * *** ***** * * = fas(a);
* * ** ** **** *** * * * ** * ** * * **
* **** **** * ****** * *** ** * * * *****
*** **** ** * * * * *** 0;

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

#include <stdlib.h>



void Fibonacci(int x)

{
* * *** ** ** * * ** k, num1, num2, i;
***** *** ** ** * = 1;
** ** * *** ** * * = 1;
* * * * * **** * ** ** == 1 || x == 2)
* * **** * ** * ** ** ** * ** * *** * **** **
* * ** * * * *** *
** * * ** **** * **
***** * *** * ** * ** ** * * * * ** = 3;i <= x;i ++)
** *** ** **** * ** ******* * * ** *
* * * ** **** ** ** * * * ** * * ** *** = num1 + num2;
* ** * *** ** * * * * *** * *** ** ***** = num2;
* ** * * * ** * ***** * ** **** * *** ** ** ***** = k;
* ** *** **** ** * * *
** ** **** * ** * **** ** * **** ** * *** * **** **** k);
** * * * ***


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

}

int main()

{
* ** ** * * * x;
** ****** **** *** * **** * * ** &x);
* * ** ** * * * **
* * * ** ** * ******* 0;

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

#include *** * * *



int printFF(int n);



int main(int argc, char *argv[]){
* * * ***** *** *** ** a,b,sum;
** * * *********** ** * * * * * *** *
** * * * * * * ** ** ** ** = printFF(a);
***** ** ** * *
*** * * ** ***** * ** *** * ** ** **
**** *** * *** ** * * ** ** * * *** *** ** * ** **
** *** ** * ** * *** 0;

}



int printFF(int n){
******* * *** * ** * f[10000]={1,1,0},i;
** ** * * ** * * ** **** i <= n; i++)
** * ** * * ** * * * * * * **** **** ** ***** * *** ** * ** ** ******* **
* *** ** * * * *** ** f[n-1];

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

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
| 820 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
| 863 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
| 1.4k 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
| 1.6k 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
| 1.4k views
12,783 questions
183,443 answers
172,219 comments
4,824 users