-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpractice1 (1).c
More file actions
40 lines (31 loc) · 781 Bytes
/
practice1 (1).c
File metadata and controls
40 lines (31 loc) · 781 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
39
40
#include <stdio.h>
#include <math.h>
int main(){
int n;
scanf("%d", &n);
double adj[n][n + 1];
for(int i = 0; i < n; i++){
for(int j = 0; j <= n; j++){
scanf("%lf", &adj[i][j]);
}
}
for(int i = 0; i < n; i++){
for(int j = 0; j < n; j++){
if(j != i){
double t = adj[j][i]/adj[i][i];
for(int k = 0; k <= n; k++){
adj[j][k] = adj[j][k] - (adj[i][k] * t);
}
}
}
}
for(int i = 0; i < n; i++){
adj[i][n] /= adj[i][i];
adj[i][i] = 1.0;
}
printf("\n");
for(int i = 0; i < n; i++){
printf("%0.5lf\t", adj[i][n]);
}
return 0;
}