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 87003d1
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Learning C++

> **NOTICE** 推荐阅读 [C++ 参考手册](https://zh.cppreference.com/w/cpp) 学习 C/C++ 语法和 STL 库。
## 使用指南

1. 安装构建工具 [xmake](https://xmake.io/)
Expand Down
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 87003d1

Please sign in to comment.