斐波那契数列(动态规划)

#include "stdafx.h"
#include <iostream>
using namespace std;
#define MAXSIZE 100
int bofei_bottom(int n)
{
	int f[MAXSIZE];
	f[0] = 0;
	f[1] = 1;
	for (int i = 2; i <= n; i++) {
		f[i] = f[i - 1] + f[i - 2];
	}
	return f[n];
}

int main()
{
	for (int i = 0; i < 10; i++)
		cout << bofei_bottom(i) << endl;
	while (1);
    return 0;
}

  

posted @ 2017-03-22 19:00  lineaar  阅读(547)  评论(0编辑  收藏  举报