题目
从(0,0)到(m,n),每次走一步,只能向上或者向右走,有多少种路径走到(m,n)
#include<stdio.h>
#include<stdlib.h>
int numroute(int m,int n)
{
int w;
if ((m == 0) && (n == 0)) w = 0;
else if ((n == 1&& m == 0) || (m == 1&&n == 0)) w = 1;
else if (n == 0) w = numroute(m - 1, n);
else if (m == 0) w = numroute(m, n - 1);
else {
w = numroute(m, n - 1) + numroute(m - 1, n);
}
return w;
}
int main() {
int m, n, w;
scanf_s("%d %d", &m, &n);
w = numroute(m, n);
printf("the number of route is:%d\n", w);
return 0;
}