11.cpp

来自「经典C语言程序设计100例1-10 如【程序1】 题目:有1、2、3、4」· C++ 代码 · 共 23 行

CPP
23
字号
/*---------------------------------------例题11-------------------------------------------------------------------*/


#include <iostream>

using namespace std;

int main()
{
	int month;
	int n1 = 1, n2 = 1, n3;
	cout <<"input the month :";
	cin>>month;
	for(int i = 2; i<month; i ++)//迭代法
	{
		n3 = n1 + n2;
		n1 = n2; 
		n2 = n3;
	}
	cout<<"The total number of the rabbits is:  "<<n3<<endl;

	return 0;
}

⌨️ 快捷键说明

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