i have problem how to split my array to make zone
my array is :
1, 2, 3, 4, 5, 6 7, 8, 9, 10, 11, 12 13, 14, 15, 16, 17, 18 19, 20, 21, 22, 23, 24 25, 26, 27, 28, 29, 30 31, 32, 33, 34, 35, 36
if i set row=3 and column 3, result must:
1 2 3 7 8 9 13 14 15
4 5 6 10 11 12 16 17 18
19 20 21 25 26 27 31 32 33
22 23 24 28 29 30 34 35 36
my problem is, only get
1 2 3 7 8 9 13 14 15
this is my source code
int dataArray[][] = new int[][]{
{1, 2, 3, 4, 5, 6},
{7, 8, 9, 10, 11, 12},
{13, 14, 15, 16, 17, 18},
{19, 20, 21, 22, 23, 24},
{25, 26, 27, 28, 29, 30},
{31, 32, 33, 34, 35, 36}
};
int row = 3;
int column = 3;
int zone = 4;
int copyArray[][] = new int[row][column];
int countJ = 0, countK = 0;
for (int j = 0; j < row; j++) {
for (int k = 0; k < column; k++) {
copyArray[countJ][countK] = dataArray[j][k];
copyArray[countK][countJ] = dataArray[k][j];
countK++;
}
countK = 0;
countJ++;
}
for (int i = 0; i < zone; i++) {
System.out.println(Arrays.deepToString(copyArray));
}
}
Thank you Advance