-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLAB(9)(+)_Matrix.cpp
More file actions
80 lines (75 loc) · 1.41 KB
/
Copy pathLAB(9)(+)_Matrix.cpp
File metadata and controls
80 lines (75 loc) · 1.41 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#include <iostream>
#include <cmath>
#include <iomanip>
using namespace std;
void matrix_output(double **mas, int N, int M)
{
int k = 79 / M;
for (int i = 0; i < N; i++)
{
for (int j = 0; j < M; j++)
{
cout << showpos << setprecision(int(k) - 9) << setw(int(k)) << mas[i][j];
if (j == M - 1)
{
cout << endl;
}
}
}
}
void matrix_create(double **mas, int N, int x)
{
double k = double(x), m;
mas[0][0] = x;
for (int i = 1; i <= N; i++)
{
if (i == 1)
{
for (int j = 2; j <= N; j++)
{
mas[i - 1][j - 1] = mas[i - 1][j - 2] / j;
}
}
else
{
for (int j = 1; j <= N; j++)
{
mas[i - 1][j - 1] = mas[i - 2][j - 1] * mas[0][j - 1];
}
}
}
for (int i = 0; i < N; i++)
{
mas[i][i] = 1;
}
for (int i = 3; i <= N; i += 2)
{
for (int j = 1; j < i; j++)
{
mas[i - 1][j - 1] *= (-1);
}
}
}
int main()
{
setlocale(LC_ALL, "rus");
cout.flags(ios::scientific);
int number = 0, x;
do
{
if (number > 7) cout << "Введите число: N < 8: ";
else cout << "Введите число: N < 8: ";
cin >> number;
} while (number > 7);
double **mas = new double *[number];
for (int i = 0; i < number; i++)
mas[i] = new double[number];
cout << "Введите число х: ";
cin >> x;
matrix_create(mas, number, x);
cout << endl << "Вывод матрицы:" << endl << endl;
matrix_output(mas, number, number);
delete[]mas;
cout << endl;
return 0;
}