Skip to content

Commit ff85a2f

Browse files
committed
fix(exercise05): 不同的编译器有不同的递归深度限制
Signed-off-by: YdrMaster <[email protected]>
1 parent 3253c06 commit ff85a2f

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

exercises/05_constexpr/main.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#include "../exercise.h"
22

3-
constexpr int fibonacci(int i) {
3+
constexpr unsigned long long fibonacci(int i) {
44
switch (i) {
55
case 0:
66
return 0;
@@ -13,10 +13,11 @@ constexpr int fibonacci(int i) {
1313

1414
int main(int argc, char **argv) {
1515
constexpr auto FIB20 = fibonacci(20);
16+
ASSERT(FIB20 == 6765, "fibonacci(20) should be 6765");
1617
std::cout << "fibonacci(20) = " << FIB20 << std::endl;
1718

1819
// TODO: 观察错误信息,修改一处,使代码编译运行
19-
constexpr auto ANS_N = 30;
20+
constexpr auto ANS_N = 100;
2021
constexpr auto ANS = fibonacci(ANS_N);
2122
std::cout << "fibonacci(" << ANS_N << ") = " << ANS << std::endl;
2223

0 commit comments

Comments
 (0)