Code For NonGeek
Would you like to react to this message? Create an account in a few clicks or log in to continue.

Matrix find number of ways to reach the other corner

Go down

Matrix find number of ways to reach the other corner Empty Matrix find number of ways to reach the other corner

Post  skyboard Mon Sep 05, 2011 12:56 am

public static int findpath(int M, int N){
int[][] array=new int[M][N];
for(int i=0;i<M;i++)
array[i][0]=1;
for(int j=0;j<N;j++)
array[0][j]=1;
for(int p=1;p<M;p++){
for(int q=1;q<N;q++){
array[p][q]=array[p-1][q]+array[p][q-1];
}
}
return array[p-1][q-1];

}

skyboard

Posts : 31
Join date : 2011-09-03

Back to top Go down

Back to top

- Similar topics

 
Permissions in this forum:
You cannot reply to topics in this forum