Skip to content

Instantly share code, notes, and snippets.

@jitsceait
Created May 4, 2014 03:51
Show Gist options
  • Select an option

  • Save jitsceait/a40f4573a07f602d5601 to your computer and use it in GitHub Desktop.

Select an option

Save jitsceait/a40f4573a07f602d5601 to your computer and use it in GitHub Desktop.
This program implements dynamic approach to find all possible paths.
#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