C Programa eliminação Gaussian

#include <stdio.h>
//using namespace std;
int main(int arqc, char *arqv[])
{
int i, j, k, n;
double fator;
//Declarando e inicializando a matriz do problema a ser resolvido
// | 2.0 3.0 -1.0 | | x1 | | 5.0 |
// | 4.0 4.0 -3.0 | x | x2 | = | 3.0 |
// | 2.0 -3.0 1.0 | | x3 | | -1.0 |
double a[3][3]= {{2.0, 3.0, -1.0}, {4.0, 4.0, -3.0},
{2.0, -3.0, 1.0}};
double b[3]= {5.0, 3.0, -1.0};
double x[3];
n = 3;
for(k=0; k<=n-2; k++){
for(i=k+1; i<=n-1; i++){
fator = a[i][k]/a[k][k];
for(j=k+1;j<=n-1;j++){
a[i][j] = a[i][j] - (fator * a[k][j]);
}
b[i] = b[i] - (fator * b[k]);
a[i][k] = 0;
}
}
for(int i = 0;i<3;i++){
for(int j = 0;j<3;j++){
printf("%f ",a[i][j]);
}
printf("\n");
}
}


Learn More :