⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 fibonacci.cpp

📁 经常使用的一些源程序.包括一些模板.在VC++6.0下通过.
💻 CPP
字号:
#include <iostream>
using namespace std;

/*main information*/
void info()
{
	cout << "fibonacci:\n";
	cout << "n = 1: f(1) = 1\n";
	cout << "n = 2: f(2) = 1\n";
	cout << "n >= 3: f(n) = f(n-1) + f(n-2)\n";
	cout << "\n\n";
}

/*fibonacci*/
long fibonacci(int f)
{
	if (f < 1){return 0;}
	else if (f == 1 || f == 2){return 1;}
	else
	{
		return fibonacci(f-1) + fibonacci(f-2);
	}
}

/*source code*/
void test()
{
	//input code here......
	int i;
	for (i = 0; i < 32; i++)
	{
		cout << "fibonacci(" << i << ")=" << fibonacci(i) << endl;
	}
}

/*information of source code owner*/
void end()
{
	cout << "\n\n\n______________\n";
	cout << "xiao zhiqiang\n";
	cout << "inxk@163.com\n";
	cout << "Sep,2006";
	getchar();
}

/*the main code*/
void main()
{
	info();
	test();
	end();
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -