题解 | #走方格的方案数#

走方格的方案数

http://www.nowcoder.com/practice/e2a22f0305eb4f2f9846e7d644dba09b

#include <iostream>
using namespace std;

int GetNum(int raw, int col)
{
    if(raw == 1 || col == 1)
    {
        return raw+col;
    }
    else
    {
        return GetNum(raw-1,  col) + GetNum(raw, col-1);
    }
}

int main()
{
    int raw,col;

    while(cin>>raw>>col)
    {
        cout<<GetNum(raw, col)<<endl;
    }

    return 0;
}
全部评论

相关推荐

点赞 收藏 评论
分享
牛客网
牛客企业服务