#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] = {
{1.0, 1.0, 8},
{230, 310, 2080}
};
char *b[3]={"リンゴ","モモ"};
int i;
Gaussian_elimination(a);
for (i = 0; i < N; i++) {
printf("%s = %f\n", b
[i
], a
[i
][N
]); }
return 0;
}
I2luY2x1ZGUgPHN0ZGlvLmg+CiNkZWZpbmUgTiAyCgp2b2lkIEdhdXNzaWFuX2VsaW1pbmF0aW9uKGRvdWJsZSBhW05dW04rMV0pewoJaW50IGksaixrOwoJZG91YmxlIHAsZDsKCQoJZm9yIChpID0gMDsgaSA8IE47IGkrKykgewogICAgCXAgPSBhW2ldW2ldOwogICAgCWZvciAoaiA9IDA7IGogPCAoTiArIDEpOyBqKyspIHsKICAgIAkJYVtpXVtqXSA9IGFbaV1bal0gLyBwOwogICAgCX0KCSAgICBmb3IgKGogPSAwOyBqIDwgTjsgaisrKSB7CiAgICAJCSAgaWYgKGkgIT0gaikgewogICAgICAgIAkJZCA9IGFbal1baV07CiAgICAgICAgCQlmb3IgKGsgPSBpOyBrIDwgKE4gKyAxKTsgaysrKSB7CiAgICAgICAgCQkJYVtqXVtrXSA9IGFbal1ba10gLSBkICogYVtpXVtrXTsKICAgICAgICAJCX0KICAgIAkJfQogICAgCX0KCSB9Cn0KIAppbnQgbWFpbih2b2lkKQp7Cglkb3VibGUgYVtOXVtOICsgMV0gPSB7CiAgICAJezEuMCwgMS4wLCA4fSwKICAgIAl7MjMwLCAzMTAsIDIwODB9Cgl9OwoJY2hhciAqYlszXT17IuODquODs+OCtCIsIuODouODoiJ9OwoJaW50IGk7CiAgCglHYXVzc2lhbl9lbGltaW5hdGlvbihhKTsgCiAKCWZvciAoaSA9IDA7IGkgPCBOOyBpKyspIHsKICAgIAlwcmludGYoIiVzID0gJWZcbiIsIGJbaV0sIGFbaV1bTl0pOwoJfQoJcmV0dXJuIDA7Cn0=