题解 | #走方格的方案数#
走方格的方案数
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.hasNext()) {
int n=sc.nextInt();
int m = sc.nextInt();
System.out.println(count(n, m));
}
}
public static int count(int n, int m) {
if (n == 1 && m == 0) {
return 1;
} else if (n == 0 && m == 1) {
return 1;
} else if (n < 0 || m < 0) {
return 0;
} else {
return count(n - 1, m) + count(n, m - 1);
}
}
}



