Skip to content

Commit

Permalink
fix(exercise05): 不同的编译器有不同的递归深度限制
Browse files Browse the repository at this point in the history
Signed-off-by: YdrMaster <[email protected]>
  • Loading branch information
YdrMaster committed Jul 10, 2024
1 parent 3253c06 commit ff85a2f
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions exercises/05_constexpr/main.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include "../exercise.h"

constexpr int fibonacci(int i) {
constexpr unsigned long long fibonacci(int i) {
switch (i) {
case 0:
return 0;
Expand All @@ -13,10 +13,11 @@ constexpr int fibonacci(int i) {

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

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

Expand Down

0 comments on commit ff85a2f

Please sign in to comment.