mirror of
https://github.com/TheAlgorithms/C-Plus-Plus.git
synced 2026-02-09 21:47:07 +08:00
made functions static to files
*BUG* in CPP lint github action
This commit is contained in:
@@ -1,29 +1,23 @@
|
||||
#include <iostream>
|
||||
using namespace std;
|
||||
|
||||
int main()
|
||||
{
|
||||
int main() {
|
||||
int mat_size, i, j, step;
|
||||
|
||||
cout << "Matrix size: ";
|
||||
cin >> mat_size;
|
||||
std::cout << "Matrix size: ";
|
||||
std::cin >> mat_size;
|
||||
|
||||
double mat[mat_size + 1][mat_size + 1], x[mat_size][mat_size + 1];
|
||||
|
||||
cout << endl
|
||||
<< "Enter value of the matrix: " << endl;
|
||||
for (i = 0; i < mat_size; i++)
|
||||
{
|
||||
for (j = 0; j <= mat_size; j++)
|
||||
{
|
||||
cin >> mat[i][j]; //Enter (mat_size*mat_size) value of the matrix.
|
||||
std::cout << std::endl << "Enter value of the matrix: " << std::endl;
|
||||
for (i = 0; i < mat_size; i++) {
|
||||
for (j = 0; j <= mat_size; j++) {
|
||||
std::cin >>
|
||||
mat[i][j]; // Enter (mat_size*mat_size) value of the matrix.
|
||||
}
|
||||
}
|
||||
|
||||
for (step = 0; step < mat_size - 1; step++)
|
||||
{
|
||||
for (i = step; i < mat_size - 1; i++)
|
||||
{
|
||||
for (step = 0; step < mat_size - 1; step++) {
|
||||
for (i = step; i < mat_size - 1; i++) {
|
||||
double a = (mat[i + 1][step] / mat[step][step]);
|
||||
|
||||
for (j = step; j <= mat_size; j++)
|
||||
@@ -31,24 +25,20 @@ int main()
|
||||
}
|
||||
}
|
||||
|
||||
cout << endl
|
||||
<< "Matrix using Gaussian Elimination method: " << endl;
|
||||
for (i = 0; i < mat_size; i++)
|
||||
{
|
||||
for (j = 0; j <= mat_size; j++)
|
||||
{
|
||||
std::cout << std::endl
|
||||
<< "Matrix using Gaussian Elimination method: " << std::endl;
|
||||
for (i = 0; i < mat_size; i++) {
|
||||
for (j = 0; j <= mat_size; j++) {
|
||||
x[i][j] = mat[i][j];
|
||||
cout << mat[i][j] << " ";
|
||||
std::cout << mat[i][j] << " ";
|
||||
}
|
||||
cout << endl;
|
||||
std::cout << std::endl;
|
||||
}
|
||||
cout << endl
|
||||
<< "Value of the Gaussian Elimination method: " << endl;
|
||||
for (i = mat_size - 1; i >= 0; i--)
|
||||
{
|
||||
std::cout << std::endl
|
||||
<< "Value of the Gaussian Elimination method: " << std::endl;
|
||||
for (i = mat_size - 1; i >= 0; i--) {
|
||||
double sum = 0;
|
||||
for (j = mat_size - 1; j > i; j--)
|
||||
{
|
||||
for (j = mat_size - 1; j > i; j--) {
|
||||
x[i][j] = x[j][j] * x[i][j];
|
||||
sum = x[i][j] + sum;
|
||||
}
|
||||
@@ -57,7 +47,7 @@ int main()
|
||||
else
|
||||
x[i][i] = (x[i][mat_size] - sum) / (x[i][i]);
|
||||
|
||||
cout << "x" << i << "= " << x[i][i] << endl;
|
||||
std::cout << "x" << i << "= " << x[i][i] << std::endl;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user