fork download
  1. #include <stdio.h>
  2.  
  3. int paths(int x, int y) {
  4. if (x == 0 || y == 0) {
  5. return 1;
  6. }
  7. return paths(x - 1, y) + paths(x, y - 1);
  8. }
  9.  
  10. int main(void) {
  11. int x, y;
  12.  
  13. scanf("%d", &x);
  14. scanf("%d", &y);
  15.  
  16. printf("(0,0)から(%d,%d)までの最短経路数は %d です。\n", x, y, paths(x, y));
  17.  
  18. return 0;
  19. }
Success #stdin #stdout 0s 5308KB
stdin
3 4
stdout
(0,0)から(3,4)までの最短経路数は 35 です。