Calculated from a position (x, y) went to (0,0) a total of how many moves
Code:
package xn.zzunit.recurrence;
/**
* 从某个位置(x,y)走到(0,0) 一共多少种走法
* @author tyrantForever
*
*/
public class Project3 {
public static void main(String[] args) {
System.out.println(methord(1,1));
}
public static int methord(int x, int y) {
if(x == 0 || y == 0) {
return 1;
}
return methord(x - 1,y) + methord(x, y - 1);
}
}
Note:
(1) The main idea of this question is: if x or y is 0 then go to (0,0) only one way of