質問編集履歴

2

修正しました

2018/04/16 05:13

投稿

soohoo
soohoo

スコア22

test CHANGED
File without changes
test CHANGED
@@ -26,7 +26,7 @@
26
26
 
27
27
 
28
28
 
29
- #include <stdio.h>
29
+ '''#include <stdio.h>
30
30
 
31
31
 
32
32
 
@@ -56,7 +56,7 @@
56
56
 
57
57
  printf( "F(%d) = %d\n", n, fibonacci( n ) );
58
58
 
59
- }
59
+ }'''
60
60
 
61
61
 
62
62
 

1

書き足しました

2018/04/16 05:12

投稿

soohoo
soohoo

スコア22

test CHANGED
File without changes
test CHANGED
@@ -26,7 +26,37 @@
26
26
 
27
27
 
28
28
 
29
+ #include <stdio.h>
29
30
 
31
+
32
+
33
+ int fibonacci( int n ) {
34
+
35
+ switch ( n ) {
36
+
37
+ case 0: return 0;
38
+
39
+ case 1: return 1;
40
+
41
+ default: return fibonacci( n - 2 ) + fibonacci( n - 1 );
42
+
43
+ }
44
+
45
+ }
46
+
47
+
48
+
49
+ void main(void) {
50
+
51
+ int n;
52
+
53
+ printf( "n = " );
54
+
55
+ scanf( "%d", &n );
56
+
57
+ printf( "F(%d) = %d\n", n, fibonacci( n ) );
58
+
59
+ }
30
60
 
31
61
 
32
62