斐波那契数列

一些经典的同时又不是特别难的,往往常常被用到,经典永远是经典,可谓一直被模仿,从未被超越,我们所做的工作,就是站在巨人的肩膀上,对巨人的理论做出进一步的发展,怎一个妙字了得!

int Fab_(int NUM)
{
	int Fab_font = 3;
	int Fab_mid;
	int Fab_next = 3;

	float Long;
	float Output = 6;
	int total = 0;

	for (;;)
	{
		Long = Output;
		while (Long != 0)
		{
			if ((Long / 2) != (int)(Long / 2))
			{
				Output = Output + 1;
				total = 0;
				Fab_font = 3;
				Fab_next = 3;
				break;
			}
			else
			{
				Long = Long - (Long / 2 + Fab_next);
				Fab_mid = Fab_next;
				Fab_next = Fab_next + Fab_font;
				Fab_font = Fab_mid;
				total++;
			}
		}
		if (Long == 0)
		{
			if (total == NUM)
			{
				break;
			}
			else
			{
				Output = Output + 1;
				total = 0;
				Fab_font = 3;
				Fab_next = 3;
			}
		}
		/*
		if (total == NUM)
		{
			break;
		}
		else
		{
			Output = Output + 1;
			total = 0;
		}
		*/
	}
	return (int)Output;
}
int Verify_(int clk)
{
	static float Fab_font = 3.0;
	static float Fab_mid;
	static float Fab_next = 3.0;
	float Long;
	int total = 0;

	Long = clk;

	while (Long!=0)
	{
		Long = Long - (Long / 2 + Fab_next);
		Fab_mid = Fab_next;
		Fab_next = Fab_next + Fab_font;
		Fab_font = Fab_mid;
		total++;
	}

	return total;
}
if (veri == cd)
{
	cout << "Correct!";
}
else
{
	cout << "Error!";
}

https://www.bilibili.com/video/av71076397

发表评论

电子邮件地址不会被公开。 必填项已用*标注