Guest User

Untitled

a guest
Feb 18th, 2018
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.09 KB | None | 0 0
  1. public APMatrix removeCross(int r, int c)
  2. {
  3. int sum = 0;
  4. APMatrix removed = new APMatrix((this.getRows()-1),(this.getColumns()-1), false);
  5.  
  6. if((r-1) < this.getRows() && (r-1)>= 0)
  7. {
  8. if((c-1) < this.getColumns() && (c-1) >= 0)
  9. {
  10. for(int i=0; i < this.getRows(); i++)
  11. {
  12.  
  13. if(i == (r-1))
  14. {
  15. continue;
  16. }
  17. for (int j = 0; j <this.getColumns(); j++)
  18. {
  19. if(j == (c-1))
  20. {
  21. continue;
  22. }
  23. else if(i < (r-1) && j > (c-1))
  24. {
  25. removed.coderage[i][j-1] += this.coderage[i][j];
  26. }
  27. else if(i < (r-1) && j < (c-1))
  28. {
  29. removed.coderage[i][j] += this.coderage[i][j];
  30. }
  31. else if(i > (r-1) && j < (c-1))
  32. {
  33. removed.coderage[i-1][j] += this.coderage[i][j];
  34. }
  35. else if(i > (r-1) && j > (c-1))
  36. {
  37. removed.coderage[i-1][j-1] += this.coderage[i][j];
  38. }
  39. }
  40.  
  41. }
  42.  
  43.  
  44. }
  45. return removed;
  46. }
  47.  
  48. else
  49. {
  50. System.out.println("The cross can't be removed because either" + r + "or" + c + "is not valid");
  51. return this;
  52. }
  53.  
  54. }
Add Comment
Please, Sign In to add comment