You are on page 1of 2

Лабораторна робота № 22

Виконав студент групи ІБК-1-1


Назаренко Артем
Варіант №17
Тема: Створення функцій користувача. Динамічні масиви.
Мета: Отримати навички роботи з покажчиками, посиланнями та
динамічними масивами.

Індивідуальне завдання А

Умова:

Блок-схема: -

Код:
#include <iostream>
#include <cmath>
#include <Windows.h>

using namespace std;

const int n = 5;

void multiply(int A[][n], int B[][n], int sizeAxsizeB, int sizeBxsizeC, int C[][n])
{
for (int i = 0; i < sizeAxsizeB; i++)
{
for (int j = 0; j < sizeBxsizeC; j++)
{
C[i][j] = 0;
for (int k = 0; k < n; k++)
{
C[i][j] += A[i][k] * B[k][j];
}
}
}
}

int trace(int A[][n], int size)


{
int sum = 0;
for (int i = 0; i < size; i++)
{
sum += A[i][i];
}
return sum;
}
int main()
{
SetConsoleCP(1251);
SetConsoleOutputCP(1251);
int A[n][n];
int A2[n][n];
int A3[n][n];
int temp[n][n];
int c, d, b;
double alpha, z;
cout << "Введите матрицу A:\n";
for (int i = 0; i < n; i++)
{
for (int j = 0; j < n; j++)
{
cin >> A[i][j];
}
}
c = trace(A, n);
multiply(A, A, n, n, A2);
d = trace(A2, n);
multiply(A, A2, n, n, A3);
multiply(A, A3, n, n, temp);
b = trace(temp, n);
alpha = 0.5;
z = c * cos(alpha) + b * c + d / tan(d) - c;
cout << "z = " << z << endl;

return 0;
}

Результат:

You might also like