请教有关循环的问题
列主元素消去法:这个程序是要将该矩阵变为上三角阵,虽然结果是下三角全部为零,但是其他值却没有改变(第一行的所有值不需要发生变化)。所以在此向大家请教一下程序出问题的地方。
#include "stdio.h"
void main()
{ int i,j,h;
double x[9],a[9][10]={
{12.38412, 2.115237, -1.061074, 1.112336, -0.113584, 0.718719, 1.742382, 3.067813, -2.031743, 2.1874369 },
{2.115237, 19.141823, -3.125432, -1.012345, 2.189736, 1.563849, -0.784165, 1.112348, 3.123124, 33.992318 },
{-1.061074, -3.125432, 15.567914, 3.123848, 2.031454, 1.836742, -1.056781, 0.336993, -1.010103, -25.173417},
{1.112336, -1.012345, 3.123848, 27.108437, 4.101011, -3.741856, 2.101023, -0.71828, -0.037585, 0.84671695},
{-0.113584, 2.189736, 2.031454, 4.101011, 19.897918, 0.431637, -3.111223, 2.121314, 1.784317, 1.784317 },
{0.71819, 1.563849, 1.836742, -3.741856, 0.431637, 9.789365, -0.103458, -1.103456, 0.238417, -86.612343},
{1.742382, -0.784165, -1.056781, 2.101023, -3.111223, -0.103458, 14.7138465, 3.123789, -2.2123474, 1.1101230 },
{3.067813, 1.112348, 0.336993, -0.71828, 2.121314, -1.103456, 3.123789, 30.719334, 4.446782, 4.719345 },
{-2.031743, 3.123124, -1.010103, -0.037585, 1.784317, 0.238417, -2.213474, 4.446782, 40.00001, -5.6784392}
};
{
for(i=1;i<9;i++)
for(h=0;h<=i-1;h++)
for(j=h;j<10;j++)
a[i][j]=a[i][j]-(a[h][j]*a[i][h])/a[h][h];
}
for(i=0;i<9;i++)
{
for(j=0;j<10;j++)
printf("%f ",a[i][j]);
}
printf("\n");
}