0 like 0 dislike
4.6k views
Show more...
[Exercise] Coding (C) - asked in Chapter 9: Functions by (5.2k points)
ID: 37370 - Available when: 2017-12-14 18:00 - Due to: Unlimited
| 4.6k views

41 Answers

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

int fib(int n){

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

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

** *** ** *** *** (fib(n-1)+fib(n-2));

}

int main(){


* **** * * * * ** *** * * input, i;



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

scanf("%d", &input);

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


* * **** ** ** **** * * * * ** * *** * * *** * * ***** * i<=input; i++)

** * * * *** ** * * * * * ** ** ****** * ** * ***** * * * ** * ** * *** ** * *
* * * * ** *** * * *** * *** * **** * ** ** ** *** * * * * * ** * ** ****** ** ** *** * *** ** * fib(i));
* *** * * ** ** ** * * ** *** *** ** * * **** * *** ** * * ** *** * * * * **
*** ** ****** * *** ** **** * ** ***** **
return 0;
* ** *** * * * *** *
answered by (-336 points)
0 0
Case 0: Wrong output
Case 1: Wrong output
Case 2: Wrong output
Case 3: Wrong output
0 like 0 dislike
Hidden content!
# include <stdlib.h>
# include <stdio.h>

int fib(int n){

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

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

* * ** * ** ** * ** (fib(n-1)+fib(n-2));

}

int main(){


* ** *** *** *** *** * ** input, i;



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

scanf("%d", &input);

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


** * * ** *** * ** **** ** * *** * ** ** *** ** **** i<=input; i++)

* * * ** * ** **** * * ** * * **** ** ** ** * * * * ** * * *** * ** ***** * * * * * ** *
***** * **** **** ** * * * * * * ** * ** ** ** ** * * ***** **** *** * ** *** * ******* * * *** * fib(i));
*** ** *** **** * * *** ** **** ** * * * * * * * * * * ***** * *** ***** ** *** * * **** *
* * * ** * **** * * **** * ** * * * * * **
return 0;
*** * * * * * * *** **
answered by (-336 points)
0 0
Case 0: Wrong output
Case 1: Wrong output
Case 2: Wrong output
Case 3: Wrong output
0 like 0 dislike
Hidden content!
# include <stdlib.h>
# include <stdio.h>

int fib(int n){

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

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

**** * * ** ***** * * (fib(n-1)+fib(n-2));

}

int main(){


** *** ********** * *** input, i;



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

scanf("%d", &input);

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


** * **** *** * * ** ***** ** * * * * ** * ** * * *** * *** i<=input; i++)

* * ** * *** * * * ***** *** * **** ** * *** * * * * * **** * **** * ** * * * **** ** *** * * * *
* *** * ** * ****** ** * **** * ** ** *** ** **** * **** * * ** ***** **** * * **** **** * fib(i));
* ** *** * ** ** **** * * * * * *** ******** ** *** **** * **** * * * * * *
* * * * * * ********* ** ** *** ** ** **
return 0;
** * * * ** * *** *
answered by (-336 points)
0 0
Case 0: Wrong output
Case 1: Wrong output
Case 2: Wrong output
Case 3: Wrong output
0 like 0 dislike
Hidden content!
# * * ******** * **
# **** ** *** **



int main()
{
** * ** * * ** * *** * * = 0,F1 = ****
*** ** ** *** * * * ** ** * * ** ** *
** ** ** * * * * * = 2;n ** ** input; n++)
* * ** * * *** **
*** * *** *** * * ****** *** * * ** ** ** ** = F0 + F1;
* * * ** * * * * * *** ******** * ** ***** * = F1;
*** *** * * * *** *** * ** * * *** * * * = Fn;
** * ** ** ** * * *
*** ** ** **** ** * * *** * **** * * ******
* ** *** * *** * 0;

}

/*F0 = 0
F1 = 1

Fn = F0 + F1 = 0 + 1 = 1
F0 = F1 = 1
F1 = Fn = 1
*/
answered by (-255 points)
0 0
Case 0: Correct output
Case 1: Correct output
Case 2: Correct output
Case 3: Correct output
0 like 0 dislike
Hidden content!
# include <stdlib.h>
# include <stdio.h>

int fib(int n){

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

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

*** *** **** ** * **** * * * (fib(n-1)+fib(n-2));

}

int main(){


*** ** ** * *** ** input, i;



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

scanf("%d", &input);

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

* * * ** * ** ** * * *** * ******* ***** ***
* * * * * *** * * * * *** * ** * ** * *** ** * * ** * * ** *** * * ** * ** * cannot less than 0\n\n");

*** *** ** **** * **** *** ** * * * * * * *** * **
* ** ****** * * * ***** * *** * * ** * ** ***** ** * ** i<=input; i++)

* * ** * ***** ** *** ** ** * ** * * ** ** *** ** *** * **** * * * * * ** * *** **** ** ***
* **** * ** ** * * * * * ** * *** * * ** *** ** * * ** **** ****** *** * * ** ******* * * fib(i));
* ** ** ** *** * * ** * * * *** * * * ***** * *** * * ********* ** ** ** **** *******
* *** ** * *** ** ** *** * ** *** *** ** **

    }

* ** * * * ** * **** * * 0;
}
answered by (-336 points)
0 0
Case 0: Wrong output
Case 1: Wrong output
Case 2: Wrong output
Case 3: Wrong output
0 like 0 dislike
Hidden content!
# include <stdlib.h>
# include <stdio.h>

int main(){

** * ** * *** *** ** * input,F0=0,F1=1,Fn,n;
* * * *** * * ** ** * * ** *** *** * *** * * *

* ******* * ** *** ** **** * ** ** (n=2; n<=input; n++)
* * * * ***** ** ***** **** * **
** * * * * * *** * * * * * *** ******* *** ***** + F1;
** ** ** ** *** ***** * ** * ** * * ** *** ** ** = F1;
** * * ****** * * ** * * * * * * **** * * = Fn;
** *** * * ** *** ***
*** * *** ** * * *** * ** * * *** * *

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

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

int Fibonacci(int i);

int main(){
* * *** * * ***** * a;
* **** ** ****** ** **** * * ** *** ***
*** * * ** *** * ** * ** * ****** * * **

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

int Fibonacci(int i){
**** ** ** * **** * ** *** == 0){
** * * ** * ******** *** * * * 0;
* **** ** ***** ****
* **** * * * * * * * ** * if(i==1){
* **** * *** * * * * ** * * * ** * * * * * 1;
* ** * ** * *** ** *
* **** ** ** * ** *** *
* * ** *** ****** * ** **** ***** * * Fibonacci(i-1)+Fibonacci(i-2);
*** ***** ** * * * *
}
answered by (-116 points)
0 0
Case 0: Correct output
Case 1: Correct output
Case 2: Correct output
Case 3: Correct output
0 like 0 dislike
Hidden content!
include<stdio.h>

int Fibonacci(int i);

int main(){
*** * ** ** * **** * * a;
* ** * **** * * ** ** **** ** ** *
** * ** * * * ** *** *** ** * * * * *

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

int Fibonacci(int i){
*** * * ** * * *** *** ** * == 0){
** * * * * ** * * ** * * ** *** ** * **** **** * ****** 0;
** * * * ** ** * **
**** * * ***** *** * ** *** if(i==1){
* ** * * *** * *** ***** *** ** * * **** * 1;
* * *** ** * ** *** ** **
*** * *** ** *** ****
***** * ** * ** *** * *** * * ** ** ** * * * * Fibonacci(i-1)+Fibonacci(i-2);
* **** ** * * * ** *****
}
answered by (-116 points)
0 0
prog.c:1:8: error: expected '=', ',', ';', 'asm' or '__attribute__' before '<' token
 include<stdio.h>
        ^
prog.c: In function 'main':
prog.c:7:5: warning: implicit declaration of function 'scanf' [-Wimplicit-function-declaration]
     scanf("%d",&a);
     ^~~~~
prog.c:7:5: warning: incompatible implicit declaration of built-in function 'scanf'
prog.c:7:5: note: include '<stdio.h>' or provide a declaration of 'scanf'
prog.c:8:5: warning: implicit declaration of function 'printf' [-Wimplicit-function-declaration]
     printf("%d",Fibonacci(a));
     ^~~~~~
prog.c:8:5: warning: incompatible implicit declaration of built-in function 'printf'
prog.c:8:5: note: include '<stdio.h>' or provide a declaration of 'printf'
prog.c:8:17: warning: implicit declaration of function 'Fibonacci' [-Wimplicit-function-declaration]
     printf("%d",Fibonacci(a));
                 ^~~~~~~~~
0 like 0 dislike
Hidden content!
*** * * * * * *** ***

int recursion(int n) {
* * ** *** *** * * * {
** * *** * ** * *** **** **** ** * * ** ** * ** * 0;
* **** ******* ** ** **
**** * *** *** * ** * * **** if(n==2) {
*** ** ** * ** * ** *** ** * * *** * ** * * 1;
* * * *** * *** * * **
*** * ******** * ** * * * * *** ** ** **** *
}

int main() {
******* * * ** ***** *** n;
* ** * * * ** ************ * ** *** ***** &n);
*** * *** ****** * * * * **** * * think the test in/out put has error.
** *** ********* *** * *** ****** ***** * * * * * ** ** * * ** fifth number of Fibonacci should be 3.
** **** ***** *** ** * * ** ***** recursion(n));
}
answered by (-120 points)
0 0
Case 0: Correct output
Case 1: Correct output
Case 2: Correct output
Case 3: Correct output
0 like 0 dislike
Hidden content!
#include ** * *

int main()
{
** *** * * n, i;
** ** **** **** *** * int Fn[100];
***** ** ** * * * ******** ** ***** ** * ***
*** ** ***** ***
* ***** * * ** ***

** ***** * ******
* * ** **** * *
* *** * = Fn[i-1] + Fn[i-2];

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



** * 0;
**** * *
answered by (-304 points)
0 0
Case 0: Correct output
Case 1: Correct output
Case 2: Correct output
Case 3: Correct output
Welcome to Peer-Interaction Programming Learning System (PIPLS) LTLab, National DongHwa University
English 中文 Tiếng Việt
IP:172.69.7.63
©2016-2025

Related questions

0 like 0 dislike
46 answers
[Exercise] Coding (C) - asked Nov 29, 2017 in Chapter 9: Functions by semicolon (5.2k points)
ID: 34912 - Available when: 2017-12-14 18:00 - Due to: Unlimited
| 5.7k views
0 like 0 dislike
93 answers
[Exercise] Coding (C) - asked Nov 2, 2017 in Chapter 6: Loops by semicolon (5.2k points)
ID: 29830 - Available when: 2017-11-02 18:00 - Due to: Unlimited
| 9.2k views
0 like 0 dislike
50 answers
[Exercise] Coding (C) - asked Dec 13, 2017 in Chapter 9: Functions by semicolon (5.2k points)
ID: 37278 - Available when: 2017-12-14 18:00 - Due to: Unlimited
| 6.4k views
0 like 0 dislike
38 answers
[Exercise] Coding (C) - asked Dec 13, 2017 in Chapter 9: Functions by semicolon (5.2k points)
ID: 37277 - Available when: 2017-12-14 18:00 - Due to: Unlimited
| 4.5k views
0 like 0 dislike
79 answers
[Exercise] Coding (C) - asked Dec 28, 2017 in Chapter 9: Functions
ID: 39986 - Available when: Unlimited - Due to: Unlimited
| 10.3k views
12,783 questions
183,442 answers
172,219 comments
4,824 users