Sie sind auf Seite 1von 5

x1

3
0.1
0.3

3 x1 - 0,1 x2 0,2 x3 = 7.85


0,1 x1 + 7 x2 0,3 x3 = -19,3
0,3 x1 - 0,2 x2 - 10 x3 = 71,4

i
1
2
3
4
5
6

x1
0
2.616666667
2.056475238
2.04600325
2.045972061
2.045971591

ea1
100
27.24036829
0.511826577
0.00152441
2.29811E-05

x2
0
-2.79452381
-3.086761483
-3.08708164
-3.087094384
-3.087094406

ea2
100
9.467452379
0.010370858
0.000412816
7.27537E-07

x2
-0.1
7
-0.2

x3
-0.2
-0.3
-10

b
7.85
-19.3
71.4

x3
0
-7.005609524
-7.016570513
-7.01687827
-7.016878951
-7.016878964

ea3

Condicion

100
0.156215766
0.004385946
9.70217E-06
1.94622E-07

continuar
continuar
continuar
continuar
fin

solucin
x1
x2
x3

2.0459716
-3.0870944
-7.016879

comprobacin
ec. 1
7.85
ec. 2
-19.3
ec. 3
71.4

#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#define L 10
#define A L
int main(void)
{
float m[L][A], a[L], cx[L], c[L];
float e, f;
int it, n, x, y;
printf(")\nNumero de incognitas del sistema: ");
scanf("%d",&n);
for(x=0; x<n; x++)
{
cx[x]=0;
a[x]=0;
}
for(y=0; y<n; y++)
{
for(x=0; x<n; x++)
{
printf("a[%d][%d]= ",y,x);
scanf("%f",&e);
m[y][x]=e;
}
printf("Y la constante C[%d]= ",y);
scanf("%f",&f);
c[y]=f;
}
for(it=0; it<20; it++)
{
for(y=0; y<n; y++)
{
for(x=0; x<n; x++)
cx[y]-=(m[y][x]*a[x])/m[y][y];
cx[y]+=(c[y]/m[y][y]);
a[y]=cx[y];
}
}
printf("Resultado: ");
for(x=0; x<n; x++)
printf("na[%d]=%.3f", x+1, a[x]);

puts("\n\n");
system("PAUSE");
return EXIT_SUCCESS;
}

Das könnte Ihnen auch gefallen