# 第39级台阶

小明刚刚看完电影《第39级台阶》，离开电影院的时候，他数了数礼堂前的台阶数，恰好是39级!

站在台阶前，他突然又想着一个问题：

如果我每一步只能迈上1个或2个台阶。先迈左脚，然后左右交替，最后一步是迈右脚，也就是说一共要走偶数步。那么，上完39级台阶，有多少种不同的上法呢？

请你利用计算机的优势，帮助小明寻找答案。


## aop

### before

```cpp
#include <iostream>
#define LEFT 0
#define RIGHT 1
using namespace std;
int stage[40][2];
```
### after

```cpp

```

## 答案

```cpp
int main()
{
    int i;
    stage[1][LEFT] = 1;
    stage[1][RIGHT] = 0;
    stage[2][LEFT] = 1;
    stage[2][RIGHT] = 1;
    for (i = 3; i <= 39; i++)
    {
        stage[i][LEFT] = stage[i - 1][RIGHT] + stage[i - 2][RIGHT];
        stage[i][RIGHT] = stage[i - 1][LEFT] + stage[i - 2][LEFT];
    }
    cout << stage[39][RIGHT] << endl;
    return 0;
}
```
## 选项


### A

```cpp
int main()
{
    int i;
    stage[1][LEFT] = 1;
    stage[1][RIGHT] = 0;
    stage[2][LEFT] = 1;
    stage[2][RIGHT] = 1;
    for (i = 3; i <= 39; i++)
    {
        stage[i][LEFT] = stage[i - 1][RIGHT] + stage[i - 2][RIGHT];
        stage[i][RIGHT] = stage[i - 1][LEFT] + stage[i - 2][LEFT];
    }
    cout << stage[39][LEFT] << endl;
    return 0;
}
```

### B

```cpp
int main()
{
    int i;
    stage[1][LEFT] = 1;
    stage[1][RIGHT] = 0;
    stage[2][LEFT] = 1;
    stage[2][RIGHT] = 1;
    for (i = 3; i <= 39; i++)
    {
        stage[i][LEFT] = stage[i + 1][RIGHT] + stage[i - 1][RIGHT];
        stage[i][RIGHT] = stage[i + 1][LEFT] + stage[i - 1][LEFT];
    }
    cout << stage[39][RIGHT] << endl;
    return 0;
}
```

### C

```cpp
int main()
{
    int i;
    stage[1][LEFT] = 1;
    stage[1][RIGHT] = 0;
    stage[2][LEFT] = 1;
    stage[2][RIGHT] = 1;
    for (i = 3; i <= 39; i++)
    {
        stage[i][LEFT] = stage[i + 1][RIGHT] + stage[i - 1][RIGHT];
        stage[i][RIGHT] = stage[i + 1][LEFT] + stage[i - 1][LEFT];
    }
    cout << stage[39][LEFT] << endl;
    return 0;
}
```
