蒟蒻求助大佬
查看原帖
蒟蒻求助大佬
244502
_Stay_楼主2021/9/12 19:56

哪里出问题了 40分

#include<bits/stdc++.h>
using namespace std;
int main()
{
	double a[50];
	a[1]=1;
	a[2]=1;
	int n,i;
	cin>>n;
	if(n==1 or n==2)
	{
		cout<<1;
		return 0;
	}
	for(i=3;i<=n;i++)
	{
		a[i]=a[i-1]+a[i-2];
	}
	cout<<a[n]<<".00";
	return 0;
 }

下面是打表

#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	cin>>n;
	double a[50]={0,1,1,2,3,5,8,13,21,34,55,89,144,233,377,610,987,1597,2584,4181,6765,10946,17711,28657,46368,75025,121393,196418,317811,514229,832040,1.34627e+006,2.17831e+006,3.52458e+006,5.70289e+006,9.22746e+006,1.49304e+007,2.41578e+007,3.90882e+007,6.3246e+007,1.02334e+008,1.6558e+008,2.67914e+008,4.33494e+008,7.01409e+008,1.1349e+009,1.83631e+009,2.97122e+009,4.80753e+009};
	cout<<a[n]<<".00";
	return 0;
 }

2021/9/12 19:56
加载中...