-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.c
52 lines (39 loc) · 1001 Bytes
/
main.c
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
#include <stdio.h>
void ff(){
float a[4][4] = {{1,0.17,-0.25,0.54},{0.47,1,0.67,-0.32},{-0.11,0.35,1,-0.74},{0.55,0.43,0.36,1}};
float f[4][1] = {{0.3},{0.5},{0.7},{0.9}};
float x[4][1] = {{0},{0},{0},{0}};
for (int i = 0;i<=3;i++) {
for (int j = 0; j <= 3; j++) {
if (i != j){
a[i][j] = a[i][j] / ((-1)*a[i][i]);
}
}
}
for (int i = 0; i <= 3; i++){
x[i][0] = f[i][0] / a[i][i];
}
for (int i = 0; i <= 3; i++){
f[i][0] = f[i][0] / a[i][i];
}
for (int i = 0; i <= 3; i++){
a[i][i] = 0;
}
float t = 0;
for (int k = 0;k <= 16;k++){
for (int i = 0;i<=3;i++) {
for (int j = 0; j <= 3; j++) {
t += (a[i][j] * x[j][0]);
}
x[i][0] = t + f[i][0];
t = 0;
}
}
for (int i = 0;i<=3;i++) {
printf("%f ",x[i][0]);
printf("%s","\n");
}
}
void main(){
ff();
};