Created
May 4, 2014 03:51
-
-
Save jitsceait/a40f4573a07f602d5601 to your computer and use it in GitHub Desktop.
This program implements dynamic approach to find all possible paths.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include<stdlib.h> | |
| #include<stdio.h> | |
| int PossiblePaths(int m,int n){ | |
| int Table[m][n]; | |
| int i,j; | |
| for(i=0;i<=m; i++){ | |
| Table[i][0] =1; | |
| } | |
| for(i=0;i<=n; i++){ | |
| Table[0][i] =1; | |
| } | |
| for(i=1; i<=m; i++ ){ | |
| for(j=1; j<=n; j++){ | |
| Table[i][j] = Table[i-1][j] + Table[i][j-1] + Table[i-1][j-1]; | |
| } | |
| } | |
| return Table[m][n]; | |
| } | |
| int main(){ | |
| printf("%d",PossiblePaths(4,4)); | |
| return 0; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment