#include <iostream>
using namespace std;
int main(){
long a[40];
int i,n;
a[0]=1;
a[1]=1;
cout<<"请输入一个小于40的正整数:"<<endl;
cin>>n;
if(n>40)
{
cout<<"数据溢出";
}
else if(n<1)
{
cout<<"数值错误";
}
else if(n=1)
{
cout<<a[0];
}
else if(n=2)
{
cout<<a[0]<<" "<<a[1]<<" ";
}
else
for (i=2;i<n;i++){
a[i]=a[i-2]+a[i-1];
cout<<a[i]<<" ";
}
return 0;
}
using namespace std;
int main(){
long a[40];
int i,n;
a[0]=1;
a[1]=1;
cout<<"请输入一个小于40的正整数:"<<endl;
cin>>n;
if(n>40)
{
cout<<"数据溢出";
}
else if(n<1)
{
cout<<"数值错误";
}
else if(n=1)
{
cout<<a[0];
}
else if(n=2)
{
cout<<a[0]<<" "<<a[1]<<" ";
}
else
for (i=2;i<n;i++){
a[i]=a[i-2]+a[i-1];
cout<<a[i]<<" ";
}
return 0;
}