Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public APMatrix removeCross(int r, int c)
- {
- {
- APMatrix lmatrix1 = new APMatrix(this.matrix.length-1, this.matrix[0].length-1, true);
- int[][] micro = new int [this.matrix.length-1][this.matrix[0].length-1];
- if(r<this.matrix.length && c<this.matrix[0].length)
- {
- for(int i =0; i<this.matrix.length-1; i++) //going through the rows
- {
- if(i!=r-1) //checks if i is equal to the number of rows
- {
- for(int j = 0; j<this.matrix[0].length-1; j++) //going through the columns
- {
- if(j!=c) //copies all but the one deleted
- {
- if(j<c-1 && i<r-1)//top left
- {
- micro[i][j]=this.matrix[i][j];
- }
- if(j>c-1 && i<r-1)//top right
- {
- micro[i][j]=this.matrix[i][j+1];
- }
- if(j<c-1&& i>r-1)//bottom left
- {
- micro[i][j]=this.matrix[i+1][j];
- }
- else
- {
- micro[i][j]=this.matrix[i+1][j+1];
- }
- }
- }
- }
- }
- return lmatrix1;
- }
- else
- {
- System.out.println("Those r and c values are not possible.");
- return this;
- }
- }
- }
Add Comment
Please, Sign In to add comment