3 תשובות
מה זה אומר "משקפת"?
שואל השאלה:
לדוגמה המערך:
123
456
789
10 11 12
אז זה יראה ככה:
123
456
456
123
public class arrayreflection {
public static void main(string[] args) {
int[][] array = {
{1, 2, 3},
{4, 5, 6},
{7, 8, 9}
};

reflectuppertolower(array);

for (int i = 0; i < array.length; i++) {
for (int j = 0; j < array[i].length; j++) {
system.out.print(array[i][j] + " ");
}
system.out.println();
}
}

public static void reflectuppertolower(int[][] array) {
int numrows = array.length;
int numcols = array[0].length;

for (int row = 0; row < numrows / 2; row++) {
for (int col = 0; col < numcols; col++) {
array[numrows - 1 - row][col] = array[row][col];
}
}
}
}