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

走方格的方案数

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

import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while (sc.hasNextInt()) {
            int m = sc.nextInt();
            int n = sc.nextInt();
            System.out.println(cal(m,n));
        }
        
    }
     private static int cal(int m,int n){
            if(m==1 || n== 1){
                return m+n;
            }
            return cal(m-1,n)+cal(m,n-1);
        }
}

全部评论

相关推荐

09-24 18:30
已编辑
长春工业大学 产品经理
小肥罗:HR就是好人的缩写哈哈哈哈
点赞 评论 收藏
分享
迷茫的大四🐶:干脆大厂搞个收费培训得了,这样就人均大厂了
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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