不多说 如题 为了保存代码

 1 #include<iostream>
 2 #include<climits>
 3 #include <cstdlib>
 4 #include <string.h>
 5 
 6 using namespace std;
 7 
 8 static char chart[201][45];
 9 static int p = 2;
10 
11 void setChart(int N);
12 
13 int main()
14 {
15     int N;
16     bool key;
17 
18     memset(chart,0,sizeof chart);
19 
20     chart[1][44] = 1;
21     chart[2][44] = 2;
22         
23     while(cin >> N)
24     {
25         key = false;
26         if(N > p)
27         {
28             setChart(N);
29         }
30         for(int i = 0; i < 45; i++)
31         {
32             if(chart[N][i] != 0)
33             {
34                 key = true;
35             }
36             if(key)
37             {
38                 char tem = chart[N][i] + 48;
39                 cout << tem ;
40             }
41         }
42         cout << endl;
43     }
44 }
45 
46 void setChart(int N)
47 {
48     while(N > p && p < 200)
49     {
50         int mem = 0;
51         for(int i = 44; i >= 0;i --)
52         {
53             chart[p + 1][i] = (chart[p][i] + chart[p - 1][i] + mem) % 10;
54             mem =  (chart[p][i] + chart[p - 1][i] + mem) / 10;
55         } 
56         p++;
57     }
58 }