Advertisement
Guest User

Untitled

a guest
Mar 24th, 2017
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.46 KB | None | 0 0
  1. public Matrix extractMinor(int riga, int colonna) {
  2.         if (this.isSquared()) {
  3.             Matrix minore = new Matrix(this.getRows() - 1, this.getCols() - 1);
  4.             int r = 0, c = 0;
  5.             for (int i = 0; i < this.getRows(); ++i) {
  6.                 if (i != riga) {
  7.                     for (int j = 0; j < this.getCols(); ++j) {
  8.                         if (j != colonna) {
  9.                             minore.setValue(r, c, this.getValue(i, j));
  10.                             c++;
  11.                         }
  12.                     }
  13.                     ++r;
  14.                 }
  15.             }
  16.             return minore;
  17.         } else
  18.             return null;
  19.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement