求斐波那契数列项

#include <iostream>
#include <cstdio>
using namespace std;
int fib(int n)
{
  // 递归终止,直接返回
  if(n == 1 || n == 2)
    return 1;
  // 两次递归调用,求和并返回
  return fib(n - 1) + fib(n - 2);
}
int main()
{
  int n;
  cin>>n;
  cout<<fib(n);
  return 0;
}

这篇文章,是又一个故事的结束...
lazy's story is continuing.
原文地址:https://www.cnblogs.com/Hello-world-hello-lazy/p/12586777.html