From 6ed99609fa6a20d7fec9b5b1334ed64a73b52d46 Mon Sep 17 00:00:00 2001 From: pr9284fn7 <2717974534@qq.com> Date: Mon, 21 Feb 2022 19:02:36 +0800 Subject: [PATCH] ADD file via upload --- 求斐波那契数列.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 求斐波那契数列.cpp diff --git a/求斐波那契数列.cpp b/求斐波那契数列.cpp new file mode 100644 index 0000000..8825208 --- /dev/null +++ b/求斐波那契数列.cpp @@ -0,0 +1,16 @@ +#include +int Fibonacci(int n); +const int maxn=1000; +int meto[maxn]; +int main() +{ + printf("%d\n",Fibonacci(40)); + return 0; +} +int Fibonacci(int n){ + if(n<=1) + return n; + if(meto[n]!=0) + return meto[n]; + return meto[n]=Fibonacci(n-1)+Fibonacci(n-2); +}