fork download
  1. #include <stdio.h>
  2.  
  3. int route(int x,int y);
  4.  
  5. int main(void) {
  6. int x,y;
  7.  
  8. scanf("%d",&x);
  9. scanf("%d",&y);
  10. printf("GOAL(%d,%d)\n",x,y);
  11.  
  12. printf("最短経路数:%d\n",route(x,y));
  13.  
  14. return 0;
  15. }
  16.  
  17. int route(int x,int y){
  18.  
  19. if(x == 0 || y == 0){
  20. return 1;
  21. }else{
  22. return route(x-1,y) + route(x,y-1);
  23. }
  24. }
Success #stdin #stdout 0s 5316KB
stdin
1
1
stdout
GOAL(1,1)
最短経路数:2