-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path5.4.cpp
More file actions
50 lines (43 loc) · 1.01 KB
/
5.4.cpp
File metadata and controls
50 lines (43 loc) · 1.01 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
#include "tasks.h"
void main_54()
{
int i, j, n, m;
cout << "ââåäè ÷èñëî óðàâíåíèé: ";
cin >> n;
cout << "ââåäè ÷èñëî íåèçâåñòíûõ: ";
cin >> m;
m += 1;
int** matrix = new int* [n];
for (i = 0; i < n; i++)
matrix[i] = new int[m];
for (i = 0; i < n; i++)
for (j = 0; j < m; j++)
{
cin >> matrix[i][j];
}
int tmp;
int* xx = new int[m];
int k;
for (i = 0; i < n; i++)
{
tmp = matrix[i][i];
for (j = n; j >= i; j--)
matrix[i][j] /= tmp;
for (j = i + 1; j < n; j++)
{
tmp = matrix[j][i];
for (k = n; k >= i; k--)
matrix[j][k] -= tmp * matrix[i][k];
}
}
xx[n - 1] = matrix[n - 1][n];
for (i = n - 2; i >= 0; i--)
{
xx[i] = matrix[i][n];
for (j = i + 1; j < n; j++) xx[i] -= matrix[i][j] * xx[j];
}
cout << "Êîðíè ñèñòåìû: ";
for (i = 0; i < n; i++)
cout << xx[i] << " ";
cout << endl;
}