This commit is contained in:
2025-03-04 22:04:34 +04:00
commit 2c6bed7589
15 changed files with 524 additions and 0 deletions

View File

@@ -0,0 +1,45 @@
package com.example.matrix.model;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
@Data
@NoArgsConstructor
@AllArgsConstructor
public class Matrix {
private int[][] data;
private int rows;
private int cols;
public Matrix(int rows, int cols) {
this.rows = rows;
this.cols = cols;
this.data = new int[rows][cols];
}
// Метод для заполнения матрицы случайными значениями
public void fillRandom(int min, int max) {
for (int i = 0; i < rows; i++) {
for (int j = 0; j < cols; j++) {
data[i][j] = min + (int) (Math.random() * (max - min + 1));
}
}
}
// Получение подматрицы (части матрицы)
public Matrix getSubMatrix(int startRow, int endRow) {
if (startRow < 0 || endRow > rows || startRow >= endRow) {
throw new IllegalArgumentException("Invalid row range");
}
int subRows = endRow - startRow;
Matrix subMatrix = new Matrix(subRows, cols);
for (int i = 0; i < subRows; i++) {
System.arraycopy(data[startRow + i], 0, subMatrix.data[i], 0, cols);
}
return subMatrix;
}
}

View File

@@ -0,0 +1,22 @@
package com.example.matrix.model;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
@Data
@NoArgsConstructor
@AllArgsConstructor
public class MinResult {
private int minValue;
private int row;
private int col;
private long processingTimeMs;
public MinResult(int minValue) {
this.minValue = minValue;
this.row = -1;
this.col = -1;
this.processingTimeMs = 0;
}
}