我已經把陣列想辦法拿掉了,幫幫我~~
#include<iostream>
#include<cmath>
using namespace std;
int main(void)
{
int n;
while(cin>>n)
{
int i;
int a0, a1, a2;
a0=1;
a1=2;
if(n>2)
{
for(i=2;i<n;i++)
{
a2=(a1+a0)%10007;
a0=a1;
a1=a2;
}
cout<<a2<<"\n";
}
else if(n==1)
{
cout<<a0<<"\n";
}
else if(n==2)
{
cout<<a1<<"\n";
}
}
return 0;
}