Skip to content

Commit bec64e1

Browse files
committed
test07.cpp
1 parent b5ffdb4 commit bec64e1

1 file changed

Lines changed: 30 additions & 0 deletions

File tree

section2/test07.cpp

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
// Copyright (c) 2020 by Chrono
2+
//
3+
// g++ test07.cpp -std=c++11 -o a.out;./a.out
4+
// g++ test07.cpp -std=c++14 -o a.out;./a.out
5+
// g++ test07.cpp -std=c++14 -I../common -o a.out;./a.out
6+
7+
#include <iostream>
8+
9+
10+
constexpr
11+
int fib(int n)
12+
{
13+
if (n == 0 || n == 1) {
14+
return 1;
15+
}
16+
17+
return fib(n - 1) + fib(n - 2);
18+
}
19+
20+
int main()
21+
{
22+
using namespace std;
23+
24+
constexpr
25+
int fib5 = fib(5);
26+
27+
cout << fib5 << endl;
28+
29+
cout << "const demo" << endl;
30+
}

0 commit comments

Comments
 (0)