Help to set the condition "below the secondary diagonal."
#include <iostream> using namespace std; int main() { int M; int N; int i, j; double** matrix; cout << endl << "M = " ; cin >> M; cout << endl << "N = " ; cin >> N; matrix = new double*[M]; for (i = 0; i < M; i++) matrix[i] = new double[N]; for (i = 0; i < M; i++) // ввод for (j = 0; j < N; j++) { cout << "Inter element " << "[" << i << "][" << j << "] "; cin >> matrix[i][j]; } cout << endl; for (i = 0; i < M; i++) { for (j = 0; j < N; j++) cout << matrix[i][j] << "\t"; cout << "\n"; } int sum = 0; for (i = 0; i < M; i++) { for (j = 0; j < N ; j++) { } } cout << endl << sum << endl; system("pause"); }
N - ito begin, and then all thematrix[i][j]will be the ones you need. Only this if the matrix is square, for non-square it is not clear what a diagonal is. - Arty OneSoul