Advertisement
Guest User

Untitled

a guest
Jan 26th, 2015
195
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.89 KB | None | 0 0
  1. public static void changeArray(int[][] original, int[][] copy ){
  2.  
  3. for (int i = 0; i < original.length; i++)
  4. for (int j = 0; j < original[0].length; j++)
  5. original[i][j] = copy[i][j];
  6.  
  7.  
  8. }
  9.  
  10. public static void horizontalFlip(int[][] a){
  11. int[][] replacement = new int[a.length][a[0].length];
  12.  
  13. for (int i = (a.length - 1), x = 0; i > -1; i--, x++)
  14. for (int j = 0, y = 0; j < a[0].length; j++, y++)
  15. replacement[x][y] = a[i][j];
  16. changeArray(a, replacement);
  17.  
  18.  
  19.  
  20. }
  21. // [4][1] [1][4]
  22. // [3][2] [2][3]
  23.  
  24. public static void verticalFlip(int[][] b){
  25. int[][] replacement = new int[b.length][b[0].length];
  26.  
  27. for (int i = 0, x = 0; i < b.length; i++, x++)
  28. for (int j = (b[0].length -1), y = 0; j > -1; j--, y++)
  29. replacement[x][y] = b[i][j];
  30. changeArray(b, replacement);
  31.  
  32.  
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement