#include
#include
#define m 5
void main()
{
float a[m][m],x[m],ratio;
int i,j,k,n;
FILE *fp;
fp=fopen("data.txt","r");
clrscr();
fscanf(fp,"%d\n",&n);
for(i=0;i
fclose(fp);
for(k=0;k
for(i=0;i
if(i==k)
continue;
ratio=a[i][k]/a[k][k];
for(j=0;j<(n+1);j++)
a[i][j]=a[i][j]-ratio*a[k][j];
}
}
for(i=0;i
for(j=0;j<=n;j++)
{
printf("%.2f\t",a[i][j]);
}
printf("\n");
}
/* for(i=0;i
x[i]=a[i][n]/a[i][i];
printf("%.2f",x[i]);
}*/
getch();
}
No comments:
Post a Comment