Advertisement
Guest User

Untitled

a guest
Jan 18th, 2018
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.93 KB | None | 0 0
  1. Implement a method: mirrorDiagonal(int[][] arr), which takes an array with the same width and height, and mirror the right upper part to the left bottom corner.
  2.  
  3.  
  4.  
  5. For example:
  6.  
  7. The original array:
  8.  
  9. 1 2 3 4 5
  10.  
  11. 0 2 3 4 5
  12.  
  13. 0 0 3 4 5
  14.  
  15. 0 0 0 4 5
  16.  
  17. 0 0 0 0 5
  18.  
  19.  
  20.  
  21. After calling mirrorDiagonal(arr), the array will become:
  22.  
  23.  
  24.  
  25. 1 2 3 4 5
  26.  
  27. 2 2 3 4 5
  28.  
  29. 3 3 3 4 5
  30.  
  31. 4 4 4 4 5
  32.  
  33. 5 5 5 5 5
  34.  
  35.  
  36.  
  37. Your code shall have this format:
  38.  
  39. public class Unit601_initials {
  40.  
  41. public static void main(String[] args) {
  42.  
  43. int[][] att = { {1, 2, 3, 4, 5}, {0, 2, 3, 4, 5}, {0, 0, 3, 4, 5}, {0, 0, 0, 4, 5}, {0, 0, 0, 0, 5} };
  44. mirrorDiaganol(att);
  45. //rto do: code to print the array.
  46. }
  47.  
  48. public static void mirrorDiaganol(int[][] arr) {
  49. // to do:
  50. }
  51.  
  52. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement