Skip to content

Commit b9bb6ca

Browse files
committed
made functions static to files
*BUG* in CPP lint github action
1 parent c93f3ef commit b9bb6ca

File tree

6 files changed

+40
-47
lines changed

6 files changed

+40
-47
lines changed
Lines changed: 21 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,54 +1,44 @@
11
#include <iostream>
2-
using namespace std;
32

4-
int main()
5-
{
3+
int main() {
64
int mat_size, i, j, step;
75

8-
cout << "Matrix size: ";
9-
cin >> mat_size;
6+
std::cout << "Matrix size: ";
7+
std::cin >> mat_size;
108

119
double mat[mat_size + 1][mat_size + 1], x[mat_size][mat_size + 1];
1210

13-
cout << endl
14-
<< "Enter value of the matrix: " << endl;
15-
for (i = 0; i < mat_size; i++)
16-
{
17-
for (j = 0; j <= mat_size; j++)
18-
{
19-
cin >> mat[i][j]; //Enter (mat_size*mat_size) value of the matrix.
11+
std::cout << std::endl << "Enter value of the matrix: " << std::endl;
12+
for (i = 0; i < mat_size; i++) {
13+
for (j = 0; j <= mat_size; j++) {
14+
std::cin >>
15+
mat[i][j]; // Enter (mat_size*mat_size) value of the matrix.
2016
}
2117
}
2218

23-
for (step = 0; step < mat_size - 1; step++)
24-
{
25-
for (i = step; i < mat_size - 1; i++)
26-
{
19+
for (step = 0; step < mat_size - 1; step++) {
20+
for (i = step; i < mat_size - 1; i++) {
2721
double a = (mat[i + 1][step] / mat[step][step]);
2822

2923
for (j = step; j <= mat_size; j++)
3024
mat[i + 1][j] = mat[i + 1][j] - (a * mat[step][j]);
3125
}
3226
}
3327

34-
cout << endl
35-
<< "Matrix using Gaussian Elimination method: " << endl;
36-
for (i = 0; i < mat_size; i++)
37-
{
38-
for (j = 0; j <= mat_size; j++)
39-
{
28+
std::cout << std::endl
29+
<< "Matrix using Gaussian Elimination method: " << std::endl;
30+
for (i = 0; i < mat_size; i++) {
31+
for (j = 0; j <= mat_size; j++) {
4032
x[i][j] = mat[i][j];
41-
cout << mat[i][j] << " ";
33+
std::cout << mat[i][j] << " ";
4234
}
43-
cout << endl;
35+
std::cout << std::endl;
4436
}
45-
cout << endl
46-
<< "Value of the Gaussian Elimination method: " << endl;
47-
for (i = mat_size - 1; i >= 0; i--)
48-
{
37+
std::cout << std::endl
38+
<< "Value of the Gaussian Elimination method: " << std::endl;
39+
for (i = mat_size - 1; i >= 0; i--) {
4940
double sum = 0;
50-
for (j = mat_size - 1; j > i; j--)
51-
{
41+
for (j = mat_size - 1; j > i; j--) {
5242
x[i][j] = x[j][j] * x[i][j];
5343
sum = x[i][j] + sum;
5444
}
@@ -57,7 +47,7 @@ int main()
5747
else
5848
x[i][i] = (x[i][mat_size] - sum) / (x[i][i]);
5949

60-
cout << "x" << i << "= " << x[i][i] << endl;
50+
std::cout << "x" << i << "= " << x[i][i] << std::endl;
6151
}
6252
return 0;
6353
}

computer_oriented_statistical_methods/Bisection_method.CPP renamed to computer_oriented_statistical_methods/bisection_method.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#include <cmath>
22
#include <iostream>
33

4-
float eq(float i) {
4+
static float eq(float i) {
55
return (std::pow(i, 3) - (4 * i) - 9); // original equation
66
}
77

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
1-
#include<stdlib.h>
2-
#include <math.h>
1+
#include <cmath>
2+
#include <cstdlib>
33
#include <iostream>
4-
float eq(float i) {
4+
5+
static float eq(float i) {
56
return (pow(i, 3) - (4 * i) - 9); // origial equation
67
}
8+
79
int main() {
810
float a, b, z, c, m, n;
911
system("clear");
@@ -12,12 +14,13 @@ int main() {
1214
if (z >= 0) {
1315
b = i;
1416
a = --i;
15-
goto START;
16-
}
17+
break;
1718
}
18-
START:
19+
}
20+
1921
std::cout << "\nFirst initial: " << a;
2022
std::cout << "\nSecond initial: " << b;
23+
2124
for (int i = 0; i < 100; i++) {
2225
float h, d;
2326
m = eq(a);
@@ -26,10 +29,10 @@ int main() {
2629
a = c;
2730
z = eq(c);
2831
if (z > 0 && z < 0.09) { // stoping criteria
29-
goto END;
32+
break;
3033
}
3134
}
32-
END:
35+
3336
std::cout << "\n\nRoot: " << c;
34-
system("pause");
37+
return 0;
3538
}

computer_oriented_statistical_methods/newton_raphson_method.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
#include <cmath>
22
#include <iostream>
33

4-
float eq(float i) {
4+
static float eq(float i) {
55
return (std::pow(i, 3) - (4 * i) - 9); // original equation
66
}
7-
float eq_der(float i) {
7+
8+
static float eq_der(float i) {
89
return ((3 * std::pow(i, 2)) - 4); // derivative of equation
910
}
1011

computer_oriented_statistical_methods/secant_method.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#include <cmath>
22
#include <iostream>
33

4-
float eq(float i) {
4+
static float eq(float i) {
55
return (pow(i, 3) - (4 * i) - 9); // original equation
66
}
77

computer_oriented_statistical_methods/successive_approximation.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
1-
21
#include <cmath>
32
#include <iostream>
43

5-
float eq(float y) { return ((3 * y) - (cos(y)) - 2); }
6-
float eqd(float y) { return ((0.5) * ((cos(y)) + 2)); }
4+
static float eq(float y) { return ((3 * y) - (cos(y)) - 2); }
5+
static float eqd(float y) { return ((0.5) * ((cos(y)) + 2)); }
76

87
int main() {
98
float y, x1, x2, x3, sum, s, a, f1, f2, gd;

0 commit comments

Comments
 (0)