vector double double sum for int sum for int sum sum for int i-- sum f

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
vector <double> Y(n,0);
double sum;
for (int i = 0; i < n; ++i)
{
sum = 0;
for (int k = 0; k < i; ++k)
{
sum += L[i][k] * Y[k];
}
Y[i] = (B[i] - sum) / L[i][i];
}
for (int i = n - 1 ; i >= 0; i--)
{
sum = 0;
for (int k = n-1; k >= i; k--)
{
sum += U[i][k] * X[k];
}
X[i] = (Y[i] - sum) / U[i][i];
cout << X[i] << endl;
}