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

走方格的方案数

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

#include<iostream>
using namespace std;

static int wcount = 0;
static int n,m;

void travel(const int& i,const int& j)
{
    if(i < n)
        travel(i+1,j);
    
    if(j < m)
        travel(i, j+1);
    
    if(i == n && j == m)
    {
        wcount++;
        return;
    }
}

int main()
{
    cin>>n>>m;
    travel(0,0);
    cout<<wcount;
}
全部评论

相关推荐

01-21 12:26
暨南大学 golang
点赞 评论 收藏
分享
评论
1
收藏
分享

创作者周榜

更多
牛客网
牛客企业服务