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

走方格的方案数

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;
}
全部评论

相关推荐

点赞 评论 收藏
分享
05-09 13:22
门头沟学院 Java
点赞 评论 收藏
分享
评论
1
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务