Untitled

  • Uploaded by: Veronica Acurio
  • 0
  • 0
  • December 2019
  • PDF

This document was uploaded by user and they confirmed that they have the permission to share it. If you are author or own the copyright of this book, please report to us by using this DMCA report form. Report DMCA


Overview

Download & View Untitled as PDF for free.

More details

  • Words: 273
  • Pages: 4
#include <stdio.h> #include #define tam 15 int n,m,i,j,k,h,l; float A[tam][tam],X[tam],C[tam][tam],B[tam],D[tam]; void lee_datos(void) { printf("Ingrese el numero ecuaciones "); scanf("%d",&m); printf("\n"); printf("Ingrese el numero de incognitas "); scanf("%d",&n); printf("\n"); if(m
float F[tam][tam]; for(j=1;j<=m;j++) { F[x][j]=U[x][j]; } for(j=1;j<=m;j++) { U[x][j]=U[y][j]; } for(j=1;j<=m;j++) { U[y][j]=F[x][j]; } } float valor_absoluto(float x) { float val; if(x<0) { val=-x; } else { val=x; } return(val); } void matriz_triangular(float V[tam][tam], float U[tam]) { //construir la matriz ampliada for(i=1;i<=m;i++) { for(j=1;j<=n;j++) { C[i][j] = A[i][j]; } } for(i=1;i<=m;i++) { C[i][n+1] = X[i]; } //convertirla en matriz triangular superior for(i=1;i<=m;i++) { for(k=1;k<=m-1;k++) { //coeficiente B[k]=-C[i+k][i]/C[i][i]; } //nueva fila for(h=i+1;h<=m+1;h++) {

}

for(l=1;l<=n+1;l++) { C[h][l]=C[h][l]+B[h-i]*C[i][l]; }

}

}

//calcular incógnitas D[n]=C[m][n+1]/C[m][n]; float tot=0, tot1=0; for(i=m-1;i>=1;i--) { tot=C[i][n+1]; for(j=n;j>=i+1;j--) { tot1=tot1+C[i][j]*D[j]; } D[i]=(tot-tot1)/C[i][i]; tot1=0; }

//resultados void main(void) { printf("\tMetodo de Eliminacion Gaussina para resolucion de Sist. de Ecuaciones\n\n"); lee_datos(); { if((m==n) && (A[1][1]!=0)) { matriz_triangular(A,X); printf("\nLa matriz triangular es:\n\n"); for(i=1;i<=m;i++) { for(j=1;j<=n+1;j++) { printf("%f\t",C[i][j]); } printf("\n"); } printf("\n\n"); if((valor_absoluto(C[m][n])==0) && (valor_absoluto(C[m][n+1])==0)) printf("El sistema tiene infinitas soluciones"); else { if((valor_absoluto(C[m][m])==0) && (C[m][m+1]!=0)) { printf("El sistema no tiene solucion\n"); } else { printf("La solución al sistema es:\n"); for(i=1;i<=m;i++) { printf("X[%d]:\t%f\n",i,D[i]); }

} } } }

getch();

}

Related Documents

Untitled
June 2020 0
Untitled
June 2020 0
Untitled
June 2020 0
Untitled
June 2020 0
Untitled
June 2020 0
Untitled
June 2020 0

More Documents from ""

Untitled
December 2019 24
Integral De Un Polinomio
December 2019 35
Esquema De Horner
December 2019 24