这题简单到不行,这题教育我,不要被方法圈住,有时候多动动笔,往后面写,规律就出来了!
1 #include <cstdio>
2
3 int main()
4 {
5 int n;
6 int c = 0;
7 scanf ( "%d",&n );
8 long s1[47];
9 while ( n != 0 )
10 {
11 int m;
12 scanf ( "%d",&m );
13 s1[0] = 1;
14 s1[1] = 2;
15 for ( int i = 2; i < m+1; ++i )
16 s1[i] = s1[i-1] + s1[i-2];
17 printf ( "Scenario #%d:\n",++c );
18 printf ( "%d\n",s1[m] );
19 printf ( "\n" );
20 --n;
21 }
22 return 0;
23 }
24
25
26