摘要: 欢迎关注:http://pchou.info/algorithm/c-cpp/2013/07/21/recursive-and-loop.html本文的代码更关注算法思想,不关注边界条件考虑经典的斐波那契数列问题1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, ...,我们很容易从数列本身的定义得到一个递推式:f(n)=f(n-1)+f(n-2),因此可以很容易的写出一个递归的函数来完成求该数列的第n项的值:long fib(int n){ if (n==0) return 0; if (n==1) return 1; if (n>1) return 阅读全文