题目:https://www.nowcoder.com/pat/2/problem/258
1 #include <iostream> 2 #include <stdio.h> 3 4 using namespace std; 5 6 long long diff[103] = { 1, 1, 2 }; 7 8 int main() 9 { 10 for (int i = 3; i<103; i++) { 11 diff[i] = diff[i - 1] + diff[i - 2]; 12 } 13 unsigned int n; 14 unsigned int a, b, d; 15 while (~scanf("%d", &n)) { 16 printf("%lld\n", diff[n]); 17 } 18 return 0; 19 }