#include <iostream>
using namespace std;
int main()
{
int n = 0;
int day = 0;
int f1,f2,f3,f4;
while(cin >> day && day != 0){
f1 = 1;
f2 = 2;
f3 = 3;
if(day == 0) return 0;
if(day < 4) f4 = day;
if(day >= 4)
for(int i = 4;i <= day;i++){
f4 = f1 + f3;
f1 = f2;
f2 = f3;
f3 = f4;
}
cout << f4 << endl;
}
return 0;
}
原文:http://www.cnblogs.com/2016zhanggang/p/5483601.html