题解 | #走方格的方案数#
走方格的方案数
http://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 num1= sc.nextInt(); int num2= sc.nextInt(); System.out.println(methods(num1,num2)); } } public static int methods(int num1,int num2){ if(num1 == 0 ||num2 == 0){ return 1; } return methods(num1-1,num2)+methods(num1,num2-1); } }