Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public APMatrix removeCross(int r, int c)
- {
- int sum = 0;
- APMatrix removed = new APMatrix((this.getRows()-1),(this.getColumns()-1), false);
- if((r-1) < this.getRows() && (r-1)>= 0)
- {
- if((c-1) < this.getColumns() && (c-1) >= 0)
- {
- for(int i=0; i < this.getRows(); i++)
- {
- if(i == (r-1))
- {
- continue;
- }
- for (int j = 0; j <this.getColumns(); j++)
- {
- if(j == (c-1))
- {
- continue;
- }
- else if(i < (r-1) && j > (c-1))
- {
- removed.coderage[i][j-1] += this.coderage[i][j];
- }
- else if(i < (r-1) && j < (c-1))
- {
- removed.coderage[i][j] += this.coderage[i][j];
- }
- else if(i > (r-1) && j < (c-1))
- {
- removed.coderage[i-1][j] += this.coderage[i][j];
- }
- else if(i > (r-1) && j > (c-1))
- {
- removed.coderage[i-1][j-1] += this.coderage[i][j];
- }
- }
- }
- }
- return removed;
- }
- else
- {
- System.out.println("The cross can't be removed because either" + r + "or" + c + "is not valid");
- return this;
- }
- }
Add Comment
Please, Sign In to add comment