Hello.
Task. Given a matrix: size [m,m]
, create a new matrix in which the k-th row and the n-th column are cut (n and k are specified by the user), respectively, the size of the new matrix [(m-1),(m-1)]
.
Here is my code
private static void CreateMatrix(int[,] ints, int value, int k, int n) { int lengthResult = value - 1; int tempColum = 0; int limitColum = n - 1; int limitLine = k - 1; var massiveResult = new int[lengthResult, lengthResult]; for (int colum = 0; colum < value; colum++) { if (colum != limitColum) { int tempLine = 0; for (int line = 0; line < value; line++) { if (line == limitLine) { if (limitLine != lengthResult) { massiveResult[tempColum, tempLine] = ints[colum, ++line]; } } else { massiveResult[tempColum, tempLine] = ints[colum, line]; } tempLine++; } tempColum++; } } DisplayArrayOf(massiveResult, lengthResult); }
He is a worker, but the question is how to optimize it or solve a problem in another way is not so trivial?
Thank you in advance.