Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static void changeArray(int[][] original, int[][] copy ){
- for (int i = 0; i < original.length; i++)
- for (int j = 0; j < original[0].length; j++)
- original[i][j] = copy[i][j];
- }
- public static void horizontalFlip(int[][] a){
- int[][] replacement = new int[a.length][a[0].length];
- for (int i = (a.length - 1), x = 0; i > -1; i--, x++)
- for (int j = 0, y = 0; j < a[0].length; j++, y++)
- replacement[x][y] = a[i][j];
- changeArray(a, replacement);
- }
- // [4][1] [1][4]
- // [3][2] [2][3]
- public static void verticalFlip(int[][] b){
- int[][] replacement = new int[b.length][b[0].length];
- for (int i = 0, x = 0; i < b.length; i++, x++)
- for (int j = (b[0].length -1), y = 0; j > -1; j--, y++)
- replacement[x][y] = b[i][j];
- changeArray(b, replacement);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement