static void Main(string[] args) { Console.WriteLine("Введите количество строк матрицы:"); int rows = int.Parse(Console.ReadLine()); Console.WriteLine("Введите количество столбцов матрицы:"); int colums = int.Parse(Console.ReadLine()); MyMatrix Matrix = new MyMatrix(rows,colums); Matrix.FillZero(ref Matrix); Matrix.Show(); Console.WriteLine("Введите количество добавляемых столбцов: "); int addedRows = int.Parse(Console.ReadLine()); rows = rows + addedRows; Matrix.ChangeRowsColums(rows, colums, ref Matrix); Matrix.Show(); Console.WriteLine("Введите количество добавляемых строк: "); int addedColums = int.Parse(Console.ReadLine()); colums = colums + addedColums; Matrix.ChangeRowsColums(rows, colums, ref Matrix); Matrix.Show(); Console.WriteLine("Введите количество удаляемых столбцов: "); int delRows = int.Parse(Console.ReadLine()); rows = rows - delRows; Matrix.ChangeRowsColums(rows,colums,ref Matrix); Matrix.Show(); Console.WriteLine("Введите количество строк: "); int delColums = int.Parse(Console.ReadLine()); colums = colums - delColums; Matrix.ChangeRowsColums(rows,colums,ref Matrix); Matrix.Show(); }
public void FillZero(ref MyMatrix Matrix) { for (int i = 0; i < rows; i++) { for (int j = 0; j < colums; j++) { Matrix[i, j] = 0; } } }
public void ChangeRowsColums(int newrows, int newcolums, ref MyMatrix currentMatrix) { MyMatrix tempMatrix = new MyMatrix(newrows, newcolums); for (int i = 0; i < newrows; i++) { for (int j = 0; j < newcolums; j++) { tempMatrix[i, j] = 0; } } currentMatrix = tempMatrix; }