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!
#include <stdio.h>



int ffff(int fa){
***** * * ** * t1=1,t2=2,i,back=0;
****** * * *** * * (fa==1 ||fa==2){
* * * * *** ** ** ****** ** * * ** ** * ** ** * 1;

    }
* **** * * *** * *** ** *
** * * * *** ** * ** ****** **** * *** ** ** *** *** *
* * ** * *** *** ** *** * ** **** * *** * * * ** ** * * *
** * * * *** * * * **** ** ***** * * ** * * * * * **
* * ** ** * * * ** * *** ******** *** ** ** *** * * * * * * * *
* ** * **** ***** ** ** ** *** * * * ***
**** * ***** * * *** * *** * * ******* * * * * back;
***** ** ** * * * * *

}



int main(){

    
* ** *** *** ** * ** a=0;
* * * * * ** * * ****** * *** * **** *
* * * *** * ** * * ** * ** * * ** * *

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

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

#include <stdlib.h>



int main()

{
** * * * ** * ** ** ** n,a,b,i,t;
* * * *** * ** ** *** * ** ****** * * **** * *
* * * ****** * ****
**** *** *** * **** * *
****** *** **** **
***** ** *** ***** * *** *** * * ***** ***

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

    }
* ** ** **** ** ** * * (n<=2)
** **** *** **** * ** *** ** * ** * ** * *** * * ** * ** * *
* ****** ** **** * * * if(n>2)
** * * **** *** ***** * * ** * ***** * ** * **** * ** ** * * * ***
**** * * * **** * * * ** 0;

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



int fib(int number)

{

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

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


* **** ** ** * * * ** ** ***** * *
* ** * **** * * * ** ** * ***
* ** * *** ** ** **** * * ** ** * (a = 3; a <= number; a++)
* * ***** **** * * ** ** * * **** *
* * * * * * * * * **** = b + c;
** ** * ** * ** * * ****** * * *** *** = c;
* **** ***** ** * ** ** * * **** = f;
* *** * * * **** **** *
* ** *** * ** *** * *******
*** ***** ** ***** ** *** f;

}



 int main()
**** **** ** * *
** *** * ** * ***** ** ** num, fibon;


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

  return 0;

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

int fib(int);

int main()

{
* * ** ** ** n;


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


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



}

int fib(int n)

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





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

#include * * * ****

#include * ****

#include <math.h>
*** * ** ** * * * **





int main()

{
*** ** * * ** * * * n , i , j ;
** * **** * * *** * * ** * ** **
** *** * ** * *** * *** * num[n];
**** * ** ** *** *** ** * = 1;
* ** * * * * ** ** ***** ** = 1;
** * ** * **** ** * * *** * ** * * ** ** *
** **** * ** *** = num[i-1] + num[i-2];
*** * * ** ** * * ****
** **** *** ** ** * ** * ** * ****
* * * * * * **** *** ** * * 0;

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

#include <stdlib.h>



int main(){
* **** * ** ** * ** * sum, num;
* ** ******* ** **** **** * ** * *** &num);
*** * * ** *** ** * ** = fib(num);
* * ********** * ****** * ** * sum);


** *** * ** *** * * a, b, big;
***** * * ****** * ** * * &a, &b);
**** * ** ** *** ** * **** = bigger(a,b);
* ** ** **** * ** ** *** *** * big);


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

}



int fib(int a){
* * ***** * *** ** i, num1=1, num2=1, fi=0;


** * * **** ** * *** *** * *******
**** ** * * * * **
**** * ** **** ** *** ** * *** * ******* * * * * * * ** enter a positive number.");
**** *** * * * ** * ** ** * **** ***** 0;

    }
* *** ** * ** **** *
* ** * * *** * * * ** * * * * * * ******** * || (a==2))
* * * * *** ** ***** * * **** * * * 1;
** * * * ** * ****** *

    {
*** * * * ** * * * **** * ** ** * ***** i<=a; i++)
** * * * ** * ** * *** *** *** **** * ** *** *** * ********** ***** **
* *** **** ** * * ** *** * *** *** * * * * * ** * ** * * *** *** *** ** ** * *** ** * * = num1 + num2;
* **** ** ** ** ** **** ** * ** ****** ** * ** * * ** * ** ** * * ***** * ** * ** = num2;
**** **** *** **** * **** ** *** * ** * * * * * *** ** ** *** * * ** *** ** = fi;
* * ** * ** *** ** * * * * *** * * *** * * * ** *
* ** * ***** ** *
*** ** ** * * * ** * fi;

}



int bigger(int numa, int numb){
******** * * * * ** * (numa>numb)
* * * * **** * ** * ** ** * ** * * * ** ** ** * numa;
*** * * *** * ***
* *** * ** * ** * **** *** ** * ** * * numb;

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

#include ** * * *

int main(void)

{
** ** ******** * a = 123, b = 456;
**** ** * ** * *ptr_a, *ptr_b;
* * * *** * ** * * *** * = * *
** * *** * * *** * * = ** ** **
* ** **** * ****** *** * *** = ****** * *ptr_a, ptr_a);
** ***** * ** ******* * = ** * *** * *ptr_b, ptr_b);
** * ** * * *** ** * * ** **** *
*** * ** * * * *** 0;

}
answered by (-64 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 (-158 points)
0 like 0 dislike
Hidden content!
#include <stdio.h>



int ffff(int fa){
** ** **** * * ** ** * *** t1=1,t2=2,i,back=0;
**** * ** *** * * ***** (fa==1 ||fa==2){
*** ***** * *** ** ** ** * ** * * ** ** * * * 1;
* * ** ** *** ***** *
** * * * * *** * ***
** ** ** * ** ** * ** *** ** *** * *** ** *** * * *
* * * * * *** * ** ******* * ***** * ** ** ** * * *** *
* ** ** * * * ** * * * * ******* * * * * * * * * * ** ** *** * * * *
**** * * * *** ** ** * * ** ** ** ***** * ** ** ** * * ** ** * ***
* *** ** * ** ** ** ** *** * ****** ** *** * ***
**** *** ** ***** ** **** ** * *** * * * * back;
** ** ** * *** * *** ******

}



int main(){

    
*** * ** ** * * * * * a=0;
**** **** * * *** * * * ***** * ***** * ******
* * * ****** ** ** * * * ****** * *****

    

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

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

#include<stdlib.h> /*1 1 2 3 5 8 13*/

#include <math.h>

int fi(int num);



int main()

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

}





int fi(int num)

{
*** * ** * ** * * k=1,i,a=1,b=1,sum=0;
* ** * ****** ** ****** * * * *
* ** **** * * * * *** ** ** ** * * * *** * ** * * * * *** ****** * *
**** * * **** ** ***

    {


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

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

}
answered by (-103 points)
Welcome to Peer-Interaction Programming Learning System (PIPLS) LTLab, National DongHwa University
English 中文 Tiếng Việt
IP:172.70.179.217
©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