Трифон 28 ноября 2019 в 08:55

Нарисовать блок-схему и программу по ней на языке с++.
Входные данные A, D - матрицы n*n, B,C - вектора размерности n*1.
Выходные данные:
D*C+3*B

Только программа, блок-схему не знаю
#include lt;iostreamgt;
#include lt;iomanipgt;
#include lt;vectorgt;
#include lt;ctimegt;
int main()
{
    using namespace std;

    const int n = 5;
    int A[n][n];
    int D[n][n];
    vectorlt;intgt; B(n);
    vectorlt;intgt; C(n);
    vectorlt;intgt; S(n);   //результирующий вектор

    //как-нибудь заполняем исходные матрицы и вектора
    srand(time(0));
    for (int i = 0; i lt; n; ++i)
    {
        for (int j = 0; j lt; n; ++j)
        {
            A[i][j] = rand() (n * n) - n * n / 2;
            D[i][j] = rand() (n * n) - n * 2;
        }
        B[i] = rand() (n * n) - n;
        C[i] = rand() (n * n) - n * n + n;
    }

    //выведем исходные данные на экран
    cout lt;lt; "matrix A:n";
    for (int i = 0; i lt; n; ++i)
    {
        for (int j = 0; j lt; n; ++j)
            cout lt;lt; setw(5) lt;lt; A[i][j];
        cout lt;lt; endl;
    }

    cout lt;lt; "nmatrix D:n";
    for (int i = 0; i lt; n; ++i)
    {
        for (int j = 0; j lt; n; ++j)
            cout lt;lt; setw(5) lt;lt; D[i][j];
        cout lt;lt; endl;
    }

    cout lt;lt; "nvector B:n";
    for (int i = 0; i lt; n; ++i)
        cout lt;lt; setw(5) lt;lt; B[i] lt;lt; endl;

    cout lt;lt; "nvector C:n";
    for (int i = 0; i lt; n; ++i)
        cout lt;lt; setw(5) lt;lt; C[i] lt;lt; endl;

    //вычислим требуемое
    for (int i = 0; i lt; n; ++i)
    {
        S[i] = 0;
        for (int j = 0; j lt; n; ++j)
            S[i] += D[i][j] * C[j];
        S[i] += 3 * B[i];
    }

    //выведем результат на экран
    cout lt;lt; "nvector S = D * C + 3 * B:n";
    for (int i = 0; i lt; n; ++i)
        cout lt;lt; setw(5) lt;lt; S[i] lt;lt; endl;

    return 0;
}

Для комментирования необходимо зарегистрироваться на сайте