M
M
max volin2020-12-22 22:15:20
C++ / C#
max volin, 2020-12-22 22:15:20

How to make it not touch the main diagonal?

#include <iostream>

using namespace std;
int main() {
    setlocale(LC_ALL, "RUS");
    int i, j, N, M;
    double S, a[5][5];
    cout << "N=";
    cin >> N;
    cout << "M=";
    cin >> M;
    cout << "Введите матрицу А \n";
    for (i = 0; i < N; i++)
        for (j = 0; j < M; j++)
            cin >> a[i][j];
    for (i = 0; i < N; a[i][0] = S / M, i++)
        for (S = j = 0; j < M; j++)
            S += a[i][j];
    cout << "выход матрицы A" << endl;
    for (i = 0; i < N; cout << endl, i++)
        for (j = 0; j < M; j++)
            cout << a[i][j] << endl;
    system("pause");
    return 0;
}

(if anything, here is the whole question (
In a square matrix of real numbers 55 A, replace all zero elements with the geometric mean of non-zero elements, except for the elements of the main diagonal.)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
E
Evgeny Petryaev, 2020-12-22
@Gremlin92

If (I!=j)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question