#include <stdio.h>
#define N 2
void Gaussian_elimination(double a[N][N+1]){
int i,j,k;
double p,d;
for (i = 0; i < N; i++) {
p = a[i][i];
for (j = 0; j < (N + 1); j++) {
a[i][j] = a[i][j] / p;
}
for (j = 0; j < N; j++) {
if (i != j) {
d = a[j][i];
for (k = i; k < (N + 1); k++) {
a[j][k] = a[j][k] - d * a[i][k];
}
}
}
}
}
int main(void)
{
double a[N][N + 1] = {
{0.08, 0.05, 21},
{1.0, 1.0, 300}
};
char b[2][4]={"x", "y"};
int i;
Gaussian_elimination(a);
for (i = 0; i < N; i++) {
printf("%s = %f\n", b
[i
], a
[i
][N
]); }
return 0;
}
I2luY2x1ZGUgPHN0ZGlvLmg+CiNkZWZpbmUgTiAyCgp2b2lkIEdhdXNzaWFuX2VsaW1pbmF0aW9uKGRvdWJsZSBhW05dW04rMV0pewogICAgaW50IGksaixrOwogICAgZG91YmxlIHAsZDsKICAgIAogICAgZm9yIChpID0gMDsgaSA8IE47IGkrKykgewogICAgICAgIHAgPSBhW2ldW2ldOwogICAgICAgIGZvciAoaiA9IDA7IGogPCAoTiArIDEpOyBqKyspIHsKICAgICAgICAgICAgYVtpXVtqXSA9IGFbaV1bal0gLyBwOwogICAgICAgIH0KICAgICAgICBmb3IgKGogPSAwOyBqIDwgTjsgaisrKSB7CiAgICAgICAgICAgIGlmIChpICE9IGopIHsKICAgICAgICAgICAgICAgIGQgPSBhW2pdW2ldOwogICAgICAgICAgICAgICAgZm9yIChrID0gaTsgayA8IChOICsgMSk7IGsrKykgewogICAgICAgICAgICAgICAgICAgIGFbal1ba10gPSBhW2pdW2tdIC0gZCAqIGFbaV1ba107CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgIH0KICAgICAgICB9CiAgICB9Cn0KCmludCBtYWluKHZvaWQpCnsKICAgIGRvdWJsZSBhW05dW04gKyAxXSA9IHsKICAgICAgICB7MC4wOCwgMC4wNSwgMjF9LAogICAgICAgIHsxLjAsIDEuMCwgMzAwfQogICAgfTsKICAgIGNoYXIgYlsyXVs0XT17IngiLCAieSJ9OwogICAgaW50IGk7CiAgCiAgICBHYXVzc2lhbl9lbGltaW5hdGlvbihhKTsgCiAKICAgIGZvciAoaSA9IDA7IGkgPCBOOyBpKyspIHsKICAgICAgICBwcmludGYoIiVzID0gJWZcbiIsIGJbaV0sIGFbaV1bTl0pOwogICAgfQogICAgcmV0dXJuIDA7Cn0K