C++ 代码
#include<cstdio>
#include<iostream>
using namespace std;
int main(void)
{
int i,n,sum,x = 0,y = 1;
cin >> n;
for(i=1;i<=n;i++)
{
if(i<3) printf("%d ",i-1);
else{
sum = x + y;
printf("%d ",sum);
if(i%2!=0) x = sum;
else y = sum;
}
}
return 0;
}