0 like 0 dislike
2.3k views

(20%)費式數列中,除了第一項第二項是一之外,之後的每一項皆為前兩項的和,請撰寫一程式,由使用者輸入N代表費是數列的第N項,程式會輸出第N項的值。

 

輸入說明:

輸入一個正整數N,代表要計算出費式數列的的N項,N大於0

 

輸出說明:輸出費式數列第N項的值。

輸入範例:
 

5



輸出範例:
 

5

 

[Exam] asked in 2017-1 程式設計(一)AD by (30k points)
ID: 43450 - Available when: 2018-01-19 18:30 - Due to: 2018-01-19 21:30
| 2.3k views

19 Answers

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

int main ()
{
** * ** ******* * x=1,y=1,z=0,n=0;
* * * * *** * * *** j;
** * * ** *** ** * * ** *** *** * *** * *
*** * *** **** * *** * * == 1)
* * * * ** ** * = x;
****** * * ** * * if (n == 2);
** *** * * * ** * ** * = y;
*** **** * ******* ** (j=2;j<n;j++)
*** ** * *** * * **
*** * ** * * * * ** **** * * ****** * * = x + y;
*** * ** * * **** ** ****** * = y;
**** * *** **** * * * * ** * * * * * * = z;
* ** * * * *** ** ** *
* * * ******* * * * * ** * ** * *** ** *

** ** * * *** ** * ** 0;
}
answered by (185 points)
0 0
Case 0: Correct output
Case 1: Correct output
Case 2: Correct output
0 like 0 dislike
Hidden content!
#include <stdio.h>

int main ()
{
*** *** ****** * ** * ** x=1,y=1,z=0,n=0;
*** *** * * * * * j;
** ** ** ** ***** ** * * ** * ** ** **
* ** ** * ******* * * == 1)
**** * * ** ****** * * *** = x;
*** * **** * * ** * *** if (n == 2);
** *** * * * * * * * = y;
** *** * ****** ***** * ** (j=2;j<n;j++)
* *** * ** * **
***** *** * ************ ** *** **** *** = x + y;
***** ** * *** *** ** * ** ** * ** * = y;
* ** *** ** * ** * *** ***** * ** ** = z;
*** ** *** ** ** ***** **
******** ***** ** ** * * * * * *

* * * * ** ** * * * * 0;
}
answered by (190 points)
0 0
Case 0: Correct output
Case 1: Correct output
Case 2: Correct output
0 like 0 dislike
Hidden content!
#include <stdio.h>

int main ()
{
* ** * ** * ** * * x=1,y=1,z=0,n=0;
*** ** ** *** *** j;
* ** ** * ** * * ***** ***** * ** * * ***
* * ** *** * * *** *** == 1)
** **** * ** *** *** ** = x;
**** ** * * * * *** if (n == 2);
**** * * * * * * * * * * = y;
* *** * * ** * * ***** ** (j=2;j<n;j++)
* ******* *** **** ******** *
*** * * *** **** * ** ** ** * * ** = x + y;
*** * *** ** *** **** ** **** * * * * = y;
**** * * * * **** * *** * ** * = z;
** * * ***** * ***
* * ** ** * ** * ** * ** **** ** ****

**** ***** *** * ** 0;
}
answered by (209 points)
0 0
Case 0: Correct output
Case 1: Correct output
Case 2: Correct output
0 like 0 dislike
Hidden content!
#include<stdio.h>
int main()
{
    int n;
* ***** *** * **** *** * ** * ** **
    {
**** ***** ** **** **** ** *** ** **** * ** ** * * arr[1000]={0};
** * * ** ** ** * **** **** * **** ** * *
** * * * ** * *** *** * * * ** * * * * * * * *
** * **** * * *** ** *** * * * * ** i;
** * * * * **** * * ** ** ** * *** * *** *** * * *** ** *
** ** ** * **** ** **** ** * *** * * **
*** * ** * * ** *** * ** ** * ** * ***** * ***** * *** *** ** ** *** *** * *** * ***
** * ** **** * * ** ** * * * * *** *
** * * *** ** * * * ** * ** * *** * ** * *** * * * ** ** ** * *** * * *
    }
}
answered by (100 points)
edited by
0 0
Case 0: Wrong output
Case 1: Wrong output
Case 2: Wrong output
0 0
Case 0: Correct output
Case 1: Wrong output
Case 2: Correct output
0 0
Case 0: Wrong output
Case 1: Wrong output
Case 2: Wrong output
0 0
Case 0: Correct output
Case 1: Correct output
Case 2: Correct output
0 like 0 dislike
Hidden content!
#include<stdio.h>
int main()
{
** ** * * ** ***** N,b,c,d=1,e=1;
** *** *** * * * * ****** **** **** *** ***
* *** * * ** * * * ** ******** ***
* *** * * *** * * ** * *
*** * * ***** ** * * * **
* * *** ** ***** *** * }
* * ** * ** ** ** ** ** ** * * **** * ***
}
answered by (228 points)
edited by
0 0
Case 0: Wrong output
Case 1: Wrong output
Case 2: Wrong output
0 0
Case 0: Wrong output
Case 1: Wrong output
Case 2: Wrong output
0 0
Case 0: Correct output
Case 1: Correct output
Case 2: Wrong output
0 0
Case 0: Correct output
Case 1: Correct output
Case 2: Wrong output
0 0
Case 0: Wrong output
Case 1: Wrong output
Case 2: Wrong output
0 0
Case 0: Correct output
Case 1: Correct output
Case 2: Wrong output
0 like 0 dislike
Hidden content!
#include<stdio.h>

int main()
{
* *** * ** * * ** * fay[1000]={0},n,i;
    
****** **** *** ** ******** *
** * ***** * * ** * **** ** ** * *
* * * * *** *********** ** * *
* **** * * * ** * * * * **** ****
* * ** * * *
* * * * * *** * ** *** * ** *
* ***** ** * * * * ****** ** * * * ** **
**** **** * ** **** * *** * * **** * * *
}
answered by (192 points)
0 0
Case 0: Wrong output
Case 1: Wrong output
Case 2: Wrong output
0 0
Case 0: Wrong output
Case 1: Wrong output
Case 2: Wrong output
0 0
Case 0: Wrong output
Case 1: Wrong output
Case 2: Wrong output
0 0
Case 0: Correct output
Case 1: Correct output
Case 2: Correct output
0 like 0 dislike
Hidden content!
#include<stdio.h>

int main()
{
* ** *** * * * * **** a=1,b=1,n=1,N,J;
    
** * * **** * **** ** * * * * * * *
** ** ** ** * *** *
* * * ** ***** * * *** ** *** * **
**** ** ** ** * * **** *
**** *** * * * **** **** * ** ** * * *** * *** *
** * ** ** ** * * * ***** * * * * * * * *** ** *
** ** * * * **** ** ** * ** ****** **** **** ***
* * ** * *** ** * *** *
* *** ** * **** * ** * * ** * *
}
answered by (215 points)
edited by
0 0
Case 0: Wrong output
Case 1: Wrong output
Case 2: Wrong output
0 0
Case 0: Correct output
Case 1: Correct output
Case 2: Correct output
0 0
Case 0: Correct output
Case 1: Correct output
Case 2: Correct output
0 like 0 dislike
Hidden content!
** * **** * ** *
int main()
{
*** * ** * int N, n=2, ** * **
*** *** * * * * * ** * ** * *
** * ** * ******
* * ** * ***** {
** * * ** **** ***** k=i+j;
*** * *** ** * * * * n++;
** * * *       * *** *** ** * * *
* **   *****   i=j+k;
* * *** * * ** * **** *** * n++;
*** * * ** ** **** ** *** * ** * * * * ** * ***
*** * *** * ** ** ** j=k+i;
* * * * ** * * n++;
* * * * ** ** * * * ** * * ** *** * ******* **
** ****** * **** * * *** }
* * * *** ** ** ** * *** * 0;
*** *   }
answered by (164 points)
0 0
Case 0: Wrong output
Case 1: Wrong output
Case 2: Wrong output
0 0
Case 0: Wrong output
Case 1: Wrong output
Case 2: Wrong output
0 0
Case 0: Correct output
Case 1: Correct output
Case 2: Wrong output
0 0
Case 0: Correct output
Case 1: Correct output
Case 2: Wrong output
0 like 0 dislike
Hidden content!
* *** *** ***** * **

int main()
{
int n=1,n1=1,n2=1;
int N,j;
********* *** ** ** *****
for(j=3;j<=N;j++)
{
n=n1+n2;
n2=n1;
n1=n; * * * *** ***** * ** *** * ** ** * * *** *** * ** *** * * * **** * * * * * * *** **
*** ** *** * ** ***** ****** ** * ** * **** * * *** * * ** ** ** ** * ** * *** * ****** **** ** ** **
} ** * * * * * ** *
* * * **** ** * *** *
* * *** **** * * ** ** *
}
answered by (174 points)
0 0
Case 0: Wrong output
Case 1: Wrong output
Case 2: Wrong output
0 0
Case 0: Correct output
Case 1: Correct output
Case 2: Correct output
Welcome to Peer-Interaction Programming Learning System (PIPLS) LTLab, National DongHwa University
English 中文 Tiếng Việt
IP:108.162.216.18
©2016-2024

Related questions

1 like 0 dislike
24 answers
[Exam] asked Jan 19, 2018 in 2017-1 程式設計(一)AD by 楊修俊 (30k points)
ID: 43456 - Available when: 2018-01-19 18:30 - Due to: 2018-01-19 21:30
| 1.5k views
1 like 0 dislike
24 answers
[Exam] asked Jan 19, 2018 in 2017-1 程式設計(一)AD by 楊修俊 (30k points)
ID: 43455 - Available when: 2018-01-19 18:30 - Due to: 2018-01-19 21:30
| 1.4k views
1 like 0 dislike
24 answers
[Exam] asked Jan 19, 2018 in 2017-1 程式設計(一)AD by 楊修俊 (30k points)
ID: 43454 - Available when: 2018-01-19 18:30 - Due to: 2018-01-19 21:30
| 1.5k views
2 like 0 dislike
24 answers
[Exam] asked Jan 19, 2018 in 2017-1 程式設計(一)AD by 楊修俊 (30k points)
ID: 43453 - Available when: 2018-01-19 18:30 - Due to: 2018-01-19 21:30
| 1.4k views
1 like 0 dislike
23 answers
[Exam] asked Jan 19, 2018 in 2017-1 程式設計(一)AD by 楊修俊 (30k points)
ID: 43452 - Available when: 2018-01-19 18:30 - Due to: 2018-01-19 21:30
| 1.3k views
12,783 questions
183,443 answers
172,219 comments
4,824 users