#include using namespace std; void multiply(double V[], double A[][], double result[], int N) { for (int i = 0; i < N; i += 1) { result[i] = 0; for (int j = 0; j < N; j += 1) result[i] += V[i] * A[i][j]; } } void print(double V[], int N) { for (int i = 0; i < N; i += 1) cout << V[i] << "\t"; cout << "\n"; } void multiply(double A[][], double B[][], double Result[][], int N) { for (int i = 0; i < N; i += 1) for (int j = 0; j < N; j += 1) { Result[i][j] = 0; for (int k = 0; k < N; k += 1) Result[i][j] += A[i][k] * B[k][j]; } } void print(double M[][], int N) { for (int i = 0; i < N; i += 1) { for (int j = 0; j < N; j += 1) cout << M[i][j] << "\t"; cout << "\n"; } } int main() { double x[4][4] = { { 1, 0, 3, -2 }, { 0, -1, 0, 1 }, { 2, -3, 0, 1 }, { 1, 1, 1, 1 } }; double y[4][4] = { { 0, 1, 3, 1 }, { 2, 1, 0, 0 }, { -3, 1, -2, 0 }, { 1, -2, -1, -1 } }; double product[4][4]; double input[4] = { 1.231, 2.94, -1.66, 1 }; double output[4]; multiply(x, y, product, 4); print(product, 4); cout << "\n"; multiply(input, product, output, 4); print(output, 4); cout << "\n"; }