Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Alexander Hirsch
703602-Compiler-Construction
Commits
45c3d5a1
Commit
45c3d5a1
authored
Feb 13, 2020
by
Alexander Hirsch
Browse files
Add fib example
parent
016929a4
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
31 additions
and
0 deletions
+31
-0
examples/fib/fib.mc
examples/fib/fib.mc
+28
-0
examples/fib/fib.stdin.txt
examples/fib/fib.stdin.txt
+1
-0
examples/fib/fib.stdout.txt
examples/fib/fib.stdout.txt
+2
-0
No files found.
examples/fib/fib.mc
0 → 100644
View file @
45c3d5a1
int fib(int n)
{
if (n
<
2)
{
return
n
;
}
return
fib
(
n
-
1)
+
fib
(
n
-
2);
}
int
main
()
{
print
("
Please
enter
a
number:
");
int
n
;
n =
read_int();
print_nl
();
int
result
;
result =
fib(n);
print
("
fib
(");
print_int
(
n
);
print
("
) =
");
print_int(result);
print_nl();
return 0;
}
examples/fib/fib.stdin.txt
0 → 100644
View file @
45c3d5a1
11
examples/fib/fib.stdout.txt
0 → 100644
View file @
45c3d5a1
Please enter a number:
fib(11) = 89
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment