#include "stdafx.h" #include "matrix.h" #include using namespace std; void del_matrix(int** &matrix, int size) //освобождение памяти выделенной под массив { for (int i = 0; i < size; i++) { delete [] matrix[i]; } delete [] matrix; matrix = 0; } int ** new_matrix(int size) // выделение памяти под целочисленный массив n*n { int** matrix = 0; int i = 0; try { matrix = new int* [size]; for (; i < size; i++) { matrix[i] = new int [size]; } return matrix; } catch(bad_alloc e) { cerr << e.what(); del_matrix(matrix,i); } } void cin_matrix(int** matrix, int size)//ввод матрицы /*int** matrix - двумерный динамический массив int size - размер матрицы */ { for (int i = 0; i < size; i++) for (int j = 0; j < size; j++) { cin >> matrix[j][i]; } cout << endl; } void print_matrix(int** matrix, int size) //вывод матрицы { for (int i = 0; i < size; i++) { for (int j = 0; j < size; j++) { cout << matrix[j][i] << " "; } cout << endl; } } int charact(int** matrix, int size, int columnnum) { int key = 0; //сумма модулей отрицательных нечетных элементов столбца for (int i = 0; i < size; i++) { if ((matrix[columnnum][i] < 0) && (matrix[columnnum] [i] %2 != 0)) key += abs(matrix[columnnum][i]); } return key; }