代码:
#include <iostream>
#include <cassert>using namespace std;
int numOfPaths(int divRow, int divCol)
{
if(divRow == 0 || divCol == 0)
{
return 1;
}
else
{
return numOfPaths(divRow - 1, divCol) + numOfPaths(divRow, divCol -1);
}
}
int main()
{
int startRow, startCol, endRow, endCol;
cout << "input start point:" << endl;
cin >> startRow >> startCol;
cout << "input end point:" << endl;
cin >> endRow >> endCol;
assert(startRow <= endRow || startCol <= endCol);
cout << "PathCount :" << numOfPaths(endRow - startRow, endCol - startCol) << endl;
return 0;
}