从A到B有多少种走法

 1 public class 从A到B有多少种走法1 {
 2 //#####################
 3 //#A                  #    
 4 //#                      #        
 5 //#                      #            
 6 //#                      #        
 7 //#                      #        
 8 //#                     B#    
 9 //#####################    
10     //从A到B有多少种走法
11     static int f(int x,int y) {
12         if(x==1||y==1)return 1;
13         return f(x-1,y)+f(x,y-1);//递归
14     }
15         public static void main(String[] args) {
16         
17         System.out.println(f(5,4));
18         
19         
20     }
21 
22 }

 

posted @ 2020-03-04 18:58  浪~子  阅读(626)  评论(0编辑  收藏  举报