Advertisement
sshomette

Untitled

Oct 18th, 2014
240
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.91 KB | None | 0 0
  1. public APMatrix removeCross(int r, int c)
  2. {
  3. r-=1;
  4. c-=1;
  5.  
  6. if (r > getRows() || c > getColumns())
  7. {
  8. System.out.println("ur bad @ dimensions REKT GG");
  9. System.out.println("have the original instead");
  10. return this;
  11. }
  12. else
  13. {
  14. APMatrix copy = new APMatrix(matrix.length-1, matrix[0].length-1, false);
  15. for(int i = 0; i < copy.getRows(); i++)
  16. {
  17. for(int j = 0; j < copy.getColumns(); j++)
  18. {
  19. if ((i < r)&& (j< c))
  20. {
  21. copy.matrix[i][j] = matrix[i][j];
  22. }
  23. else if (i == r || j == c)
  24. {
  25. continue;
  26. }
  27. else if (i > r || j > c)
  28. {
  29. if (i > r && j > c)
  30. {
  31. copy.matrix[i][j] = matrix[i+1][j+1];
  32. }
  33. else if (i > r)
  34. {
  35. copy.matrix[i][j] = matrix[i+1][j];
  36. }
  37. else if (j > c)
  38. {
  39. copy.matrix[i][j] = matrix[i][j+1];
  40. }
  41. }
  42. }
  43. }
  44. return copy;
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement