Suppose I have a matrix of size, say 5*6. I need all the sub matrices, that is, of size 1*1, 1*2, 2*5,3*2,5*4 etc. How do I obtain it?
for (i = 0; i < n; i++) {
for (j = 0; j < m; j++) {
int arr[][] = new int[i + 1][j + 1];
for (x = 0; x < i + 1; x++) {
for (y = 0; y < j + 1; y++) {
arr[x][y] = a[x][y];
System.out.print(arr[x][y] + " ");
}
System.out.println();
}
System.out.println("*********next********");
}
}
This is my code till now. But this is printing the subarray of desired sizes only starting from 0,0 index.