#include <stdio.h>
#include <math.h>
/* Guss-Jordan */
#define N 3
int main() {
int i, j, k, x, y;
double r, max;
double a[N][N + 1] = {
{ 2.0, 3.0, 1.0, 4.0 },
{ 4.0, 1.0, -3.0, -2.0 },
{-1.0, 2.0, 2.0, 2.0 } };
/* forward */
for (i = 0; i < N; i++) {
/* pivotting */
k = i;
for (j = i + 1; j < N; j++)
if (max
< fabs(a
[j
][i
])) { k = j;
}
if (k != i)
for (j = 0; j <= N; j++) {
r = a[k][j];
a[k][j] = a[i][j];
a[i][j] = r;
}
/* pivotting finished */
r = a[i][i];
for (j = i ; j <= N; j++)
a[i][j] /= r;
for (j = i + 1; j < N; j++) {
r = a[j][i];
for (k = 0; k <= N; k++) {
a[j][k] /= r;
a[j][k] -= a[i][k];
}
}
}
/* backward */
for (i = N - 1; i >= 0; i--) {
for (j = i - 1; j >= 0; j--) {
a[j][N] -= a[i][N] * a[j][i];
a[j][i] = 0.0;
}
}
for (y = 0; y < N; y++) {
for (x = 0; x <= N; x++)
}
return 0;
}
/* end */
I2luY2x1ZGUgPHN0ZGlvLmg+CiNpbmNsdWRlIDxtYXRoLmg+CgovKiBHdXNzLUpvcmRhbiAqLwojZGVmaW5lIE4gMwppbnQgbWFpbigpIHsKICBpbnQgaSwgaiwgaywgeCwgeTsKICBkb3VibGUgciwgbWF4OwogIGRvdWJsZSBhW05dW04gKyAxXSA9IHsKICAgIHsgMi4wLCAgMy4wLCAgMS4wLCAgNC4wIH0sCiAgICB7IDQuMCwgIDEuMCwgLTMuMCwgLTIuMCB9LCAKICAgIHstMS4wLCAgMi4wLCAgMi4wLCAgMi4wIH0gfTsKCiAgLyogZm9yd2FyZCAqLwogIGZvciAoaSA9IDA7IGkgPCBOOyBpKyspIHsKICAgIC8qIHBpdm90dGluZyAqLwogICAgbWF4ID0gZmFicyhhW2ldW2ldKTsKICAgIGsgPSBpOwogICAgZm9yIChqID0gaSArIDE7IGogPCBOOyBqKyspCiAgICAgIGlmIChtYXggPCBmYWJzKGFbal1baV0pKSB7CiAgICAgICAgbWF4ID0gZmFicyhhW2pdW2ldKTsKICAgICAgICBrID0gajsKICAgICAgfQogICAgaWYgKGsgIT0gaSkKICAgICAgZm9yIChqID0gMDsgaiA8PSBOOyBqKyspIHsKICAgICAgICByID0gYVtrXVtqXTsKICAgICAgICBhW2tdW2pdID0gYVtpXVtqXTsKICAgICAgICBhW2ldW2pdID0gcjsKICAgICAgfQogICAgLyogcGl2b3R0aW5nIGZpbmlzaGVkICovCgogICAgciA9IGFbaV1baV07CiAgICBmb3IgKGogPSBpIDsgaiA8PSBOOyBqKyspCiAgICAgIGFbaV1bal0gLz0gcjsKCiAgICBmb3IgKGogPSBpICsgMTsgaiA8IE47IGorKykgewogICAgICByID0gYVtqXVtpXTsKICAgICAgZm9yIChrID0gMDsgayA8PSBOOyBrKyspIHsKICAgICAgICBhW2pdW2tdIC89IHI7CiAgICAgICAgYVtqXVtrXSAtPSBhW2ldW2tdOwogICAgICB9CiAgICB9CiAgfQoKICAvKiBiYWNrd2FyZCAqLwogIGZvciAoaSA9IE4gLSAxOyBpID49IDA7IGktLSkgewogICAgZm9yIChqID0gaSAtIDE7IGogPj0gMDsgai0tKSB7CiAgICAgIGFbal1bTl0gLT0gYVtpXVtOXSAqIGFbal1baV07CiAgICAgIGFbal1baV0gPSAwLjA7CiAgICB9CiAgfQogIGZvciAoeSA9IDA7IHkgPCBOOyB5KyspIHsKICAgIGZvciAoeCA9IDA7IHggPD0gTjsgeCsrKQogICAgICBwcmludGYoIiUrLjJmICIsIGFbeV1beF0pOwogICAgcHV0Y2hhcignXG4nKTsKICB9CiAgcHV0Y2hhcignXG4nKTsKICByZXR1cm4gMDsKfQovKiBlbmQgKi8K