package sspr1;

import java.io.FileWriter;
import java.io.IOException;
import java.util.Random;

public class MatrixGeneration {
    public static int[][] generateMatrix(int size) {
        int[][] matrix = new int[size][size];
        Random random = new Random();
        for (int i = 0; i < size; i++) {
            for (int j = 0; j < size; j++) {
                matrix[i][j] = random.nextInt(1000);
            }
        }
        return matrix;
    }

    public static void writeMatrixToFile(int[][] matrix, String filename) throws IOException {
        try (FileWriter writer = new FileWriter(filename)) {
            for (int[] row : matrix) {
                for (int value : row) {
                    writer.write(value + " ");
                }
                writer.write("\n");
            }
        }
    }
}
