October 14, 2008 thumb Invers Matrix

THE INVERS OF MATRIX USING GAUSS-JORDAN METHODE
/* CALCULATE THE INVERS OF MATRIX USING GAUSS-JORDAN METHODE*/
/*it compile using devC++ you, it implement methode of gauss jordan to invers matrix*/
#include “stdio.h”
#include “conio.h”
main(void)
{ int p[20], a[20][20], t;
int m, i, j, k, x;
printf(“\ninsert size of matrix : \n”);
scanf(“%d”, &m);
printf(“\ninsert the matrix element step by step”);
/* read the matrix */
for(i=1; i { printf(“\n”);
for(j=1; j { printf(“A(%d,%d)= “,i, j);
scanf(“%d”, &a[i][j]);
}
}
/* print the matrix to konsole*/
printf(“\nthe matrix: “);
for(i=1; i { printf(“\n”);
for(j=1; j printf(” %2d”, a[i][j]);
}
/* invertions proses */
for(i=1; i { p[i] = a[i][j];
a[i][j] = 1;
for(j=1; j { a[i][j] = a[i][j]/p[i];
}
for(k=1; k { if(k != i)
{ t = a[k][i];
a[k][i] = 0;
for(x=1; x a[k][x] = a[k][x] – a[i][x] * t;
}
}
}
/* print the invertions matrix to konsole*/
printf(“\n\invertion matrix : \n”);
for(i =1; i { for(j=1; j printf(” %d”, a[i][j]);
printf(” \n”);
}
getch();
}

Comments

total comments