forked from AllAlgorithms/cpp
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmatrix_linear.cpp
More file actions
38 lines (35 loc) · 876 Bytes
/
matrix_linear.cpp
File metadata and controls
38 lines (35 loc) · 876 Bytes
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
// represent linear equation in form of matrix
#include<iostream.h>
#include<conio.h>
using namespace std;
int main(void)
{
char var[] = { 'x', 'y', 'z', 'w' };
cout << "Enter the number of variables in the equations: ";
int n;
cin >> n;
cout << "\nEnter the coefficients of each variable for each equations";
cout << "\nax + by + cz + ... = d";
int mat[n][n];
int constants[n][1];
for (int i = 0; i < n; i++)
{
for (int j = 0; j < n; j++)
{
cin >> mat[i][j];
}
cin >> constants[i][0];
}
cout << "Matrix representation is: ";
for (int i = 0; i < n; i++)
{
for (int j = 0; j < n; j++)
{
cout << " " << mat[i][j];
}
cout << " " << var[i];
cout << " = " << constants[i][0];
cout << "\n";
}
return 0;
}