AC代码:
#include <iostream> #include <cstdio> #include <cstdlib> using namespace std; int main(void) { freopen("in.txt","r",stdin); int n; while(scanf("%d",&n)!=EOF) { long long int count,count1,count2; for(int i=1;i<=n;i++) { if(i==1) { count1 = 1; count = count1; } else if(i==2) { count2 = 2; count = count2; } else { count = count1 + count2; count1 = count2; count2 = count; } } printf("%lld ",count); } fclose(stdin); system("pause"); return 0; }