Численные методы решения прикладных задач - page 46

46
Next i
x(1) = (F(1) - A(1, 2) * G(2) - A(1, 3) * G(3) - A(1, 4) * G(4)) / A(1, 1)
x(2) = (F(2) - A(2, 1) * G(1) - A(2, 3) * G(3) - A(2, 4) * G(4)) / A(2, 2)
x(3) = (F(3) - A(3, 1) * G(1) - A(3, 2) * G(2) - A(3, 4) * G(4)) / A(3, 3)
x(4) = (F(4) - A(4, 1) * G(1) - A(4, 2) * G(2) - A(4, 3) * G(3)) / A(4, 4)
k = k + 17
Wend
ActiveSheet.Cells(16, 3).Value = k
For i = 1 To n
ActiveSheet.Cells(11 + i, 3).Value = x(i)
Next i
'Метод Зейделя
For i = 1 To n
x(i) = 0
G(i) = 100
Next i
k = 0
While toch(x(), G()) = False
For i = 1 To n
G(i) = x(i)
Next i
x(1) = (F(1) - A(1, 2) * x(2) - A(1, 3) * x(3) - A(1, 4) * x(4)) / A(1, 1)
x(2) = (F(2) - A(2, 1) * x(1) - A(2, 3) * x(3) - A(2, 4) * x(4)) / A(2, 2)
x(3) = (F(3) - A(3, 1) * x(1) - A(3, 2) * x(2) - A(3, 4) * x(4)) / A(3, 3)
x(4) = (F(4) - A(4, 1) * x(1) - A(4, 2) * x(2) - A(4, 3) * x(3)) / A(4, 4)
k = k + 1
Wend
ActiveSheet.Cells(16, 4).Value = k
For i = 1 To n
ActiveSheet.Cells(11 + i, 4).Value = x(i)
Next i
End If
End Sub
Создание кнопки описано во введении.
Метод простой итерации и метод Зейделя. Решение в Microsoft
Visual Studio.
Код программы на языке С++:
// pr1 SLAU.cpp: определяет точку входа для консольного приложения.
//
#include
"stdafx.h"
#include
"stdafx.h"
#include
<iostream>
#include
<math.h>
usingnamespace
std;
double
a[4][4]={{10, 2, 3, 4},
{-1, 21, -3, 4},
{0, 1, -5, 1},
{1, 1, 1, 8}};
double
b[4]={1, -2, 3, 10};
double
x[4]={0, 0, 0, 0};
I...,36,37,38,39,40,41,42,43,44,45 47,48,49,50,51,52,53,54,55,56,...284
Powered by FlippingBook