Guest User

Untitled

a guest
Feb 18th, 2018
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.11 KB | None | 0 0
  1. public APMatrix removeCross(int r, int c)
  2. {
  3. {
  4. APMatrix lmatrix1 = new APMatrix(this.matrix.length-1, this.matrix[0].length-1, true);
  5. int[][] micro = new int [this.matrix.length-1][this.matrix[0].length-1];
  6.  
  7. if(r<this.matrix.length && c<this.matrix[0].length)
  8. {
  9. for(int i =0; i<this.matrix.length-1; i++) //going through the rows
  10. {
  11.  
  12. if(i!=r-1) //checks if i is equal to the number of rows
  13. {
  14.  
  15. for(int j = 0; j<this.matrix[0].length-1; j++) //going through the columns
  16. {
  17. if(j!=c) //copies all but the one deleted
  18. {
  19. if(j<c-1 && i<r-1)//top left
  20. {
  21. micro[i][j]=this.matrix[i][j];
  22. }
  23. if(j>c-1 && i<r-1)//top right
  24. {
  25. micro[i][j]=this.matrix[i][j+1];
  26. }
  27. if(j<c-1&& i>r-1)//bottom left
  28. {
  29. micro[i][j]=this.matrix[i+1][j];
  30. }
  31. else
  32. {
  33. micro[i][j]=this.matrix[i+1][j+1];
  34. }
  35. }
  36.  
  37. }
  38. }
  39. }
  40. return lmatrix1;
  41. }
  42. else
  43. {
  44. System.out.println("Those r and c values are not possible.");
  45. return this;
  46. }
  47. }
  48. }
Add Comment
Please, Sign In to add comment