
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Count All Possible Paths from Top Left to Bottom Right of a MxN Matrix in C++
In this tutorial, we will be discussing a program to find the number of possible paths from top left to bottom right of a mXn matrix.
For this we will be provided with a mXn matrix. Our task is to find all the possible paths from top left to bottom right of the given matrix.
Example
#include <iostream> using namespace std; //returning count of possible paths int count_paths(int m, int n){ if (m == 1 || n == 1) return 1; return count_paths(m - 1, n) + count_paths(m, n - 1); } int main(){ cout << count_paths(3, 3); return 0; }
Output
6
Advertisements