Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <math.h>
- #define N 4
- int main(void)
- {
- double A[N][N]={{2,1,4,1},{3,4,-1,-1},{1,-4,1,5},{2,-2,1,3}}, b[N]={-4,3,9,7};
- int i,j,k;
- for (i=0;i<N;i++)
- {
- for (j=i+1;j<N;j++)
- {
- double c=A[j][i]/A[i][i];
- for (k=i;k<N;k++)
- {
- A[j][k]=A[j][k] - c*A[i][k];
- }
- b[j]=b[j]-c*b[i];
- }
- }
- for (i=0;i<N;i++)
- {
- for (j=0;j<N;j++)
- {
- printf("%8.3lf",A[i][j]);
- if (j==(N-1))
- printf("\n");
- else
- printf(" ");
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement