#include <stdio.h>
#include <math.h>
void pib(double x[][5], int num){
double c[5]={0};
for(int j=0;j<4;j++){
for(int i=1+j;i<num;i++){
for(int n=0;n<5;n++){
c[n] = x[j][n];
x[j][n] = x[i][n];
x[i][n] = c[n];
}
}
for(int a=1+j;a<num;a++){
double det = x[a][j]/x[j][j];
for(int b=j;b<5;b++){
x[a][b] -= x[j][b]*det;
}
}
}
}
}
void gyo(double x[][5], int num){
for (int i = 0; i < num; i++) {
for (int j = 0; j < 5; j++) {
}
}
}
void sol(double x[][5], int num){
double x4 = x[3][4]/x[3][3];
double x3 = (x[2][4]-x[2][3]*x4)/x[2][2];
double x2 = (x[1][4]-x[1][3]*x4-x[1][2]*x3)/x[1][1];
double x1 = (x[0][4]-x[0][3]*x4-x[0][2]*x3-x[0][1]*x2)/x[0][0];
printf("x1 = %f, x2 = %f, x3 = %f, x4 = %f",x1
,x2
,x3
,x4
); }
int main(void) {
double x[][5] = {
{3, 1.5, -6, 4.8, 1.2},
{1, 1.5, -2, -2.4, 0.6},
{0, -1.5, -2, -1, -2.4},
{2, 4, -1.8, -0.6, 0}};
pib(x, 4);
gyo(x, 4);
sol(x, 4);
return 0;
}
I2luY2x1ZGUgPHN0ZGlvLmg+CiNpbmNsdWRlIDxtYXRoLmg+CiAKdm9pZCBwaWIoZG91YmxlIHhbXVs1XSwgaW50IG51bSl7Cglkb3VibGUgY1s1XT17MH07Cglmb3IoaW50IGo9MDtqPDQ7aisrKXsKCQlmb3IoaW50IGk9MStqO2k8bnVtO2krKyl7CgkJCWlmKGZhYnMoeFtpXVtqXSk8ZmFicyh4W2ldW2pdKSl7CgkJCQlmb3IoaW50IG49MDtuPDU7bisrKXsKCQkJCQljW25dID0geFtqXVtuXTsKCQkJCQl4W2pdW25dID0geFtpXVtuXTsKCQkJCQl4W2ldW25dID0gY1tuXTsKCQkJCX0KCQkJfQoJCQlmb3IoaW50IGE9MStqO2E8bnVtO2ErKyl7CgkJCQlkb3VibGUgZGV0ID0geFthXVtqXS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