编辑代码

#include <iostream>
using namespace std;
int diTui(int n)
{
	if(n==1||n==2)
	return n;

	int methods,f1,f2;
	methods=0;
	f1=1;
	f2=2;
	int step=3;
	for(;step<=n;step++)
	{
		methods=f1+f2;
		f1=f2;
		f2=methods;
	}
	return methods;
}

int main() {
    int n,methods;
	cin>>n;
	methods=diTui(n);
	cout<<"递推:共有"<<methods<<"种方法"<<endl;
	return 0;
}