Module Module1
Sub Main()
Dim m, a, i, j, y, n, p, MAXJ, MAXI, MAX As Double
Console.Write("Введите количество уравнений системы= ")
n = Val(Console.ReadLine()) 'кол-во строк'
m = n + 1 'кол-во столбцов = кол-ву строк'
Dim x(n, m) As Single
For i = 1 To n
For j = 1 To m
x(i, j) = InputBox("Ввод коэффициента (" & i & " ; " & j & ")") 'ввод коэффициентов матрицы A|B'
Next j
Next i
'----------------------------------------------------------------------—
'----------------------------------------------------------------------—
'ВЫВОД УРАВНЕНИЙ
Console.WriteLine()
Console.Write("введенные уравнения:")
Console.WriteLine()
For i = 1 To n
For j = 1 To m
If j < m Then
Console.Write("({0}x{1})", x(i, j), j)
If j < m - 1 Then
Console.Write("+")
End If
Else
Console.Write("={0}", x(i, j))
End If
Next j
Console.WriteLine()
Next i
'----------------------------------------------------------------------—
'----------------------------------------------------------------------—
Dim f(n, m) As Single
For i = 1 To n
For j = 1 To m
f(i, j) = x(i, j)
Next j
Next i
For i = 1 To n
MAX = x(i, 1)
MAXI = i
MAXJ = 1
For j = 1 To m - 1
If MAX < x(i, j) Then
MAX = x(i, j)
MAXI = i
MAXJ = j
End If
Next j
For y = 1 To m - 1
p = x(MAXJ, y)
x(MAXJ, y) = x(MAXI, y)
x(MAXI, y) = p
p = f(MAXJ, y)
f(MAXJ, y) = f(MAXI, y)
f(MAXI, y) = p
Next y
p = f(MAXJ, m)
f(MAXJ, m) = f(MAXI, m)
f(MAXI, m) = p
Next i
Console.WriteLine()
Console.Write("упорядоченные уравнения: ")
Console.WriteLine()
For i = 1 To n
For j = 1 To m
If j < m Then
Console.Write("({0}x{1})", f(i, j), j)
If j < m - 1 Then
Console.Write("+")
End If
Else
Console.Write("={0}", f(i, j))
End If
Next j
Console.WriteLine()
Next i
'----------------------------------------------------------------------—
'----------------------------------------------------------------------—
Console.WriteLine()
Console.Write("выражаем x:")
Console.WriteLine()
Dim k(n, m) As Single
For i = 1 To n
For j = 1 To m
k(i, j) = x(i, j)
Next j
Next i
For i = 1 To n
a = f(i, i)
k(i, i) = a / a
For j = 1 To n
If (j < i Or j > i) Then
k(i, m) = f(i, m) / a
k(i, j) = -((f(i, j)) / a)
End If
Next j
Next i
For i = 1 To n
Console.Write("{0}x{1}=", k(i, i), i)
For j = 1 To m
If j < m And (j < i Or j > i) Then
Console.Write("({0}x{1})", k(i, j), j)
If j < m Then
Console.Write("+")
End If
End If
Next j
Console.Write("{0}", k(i, m))
Console.WriteLine()
Next i
'----------------------------------------------------------------------—
'----------------------------------------------------------------------—
Dim dMAX, r, g As Double
Console.WriteLine()
Console.Write("высчитываем иксы:")
Console.WriteLine()
g = 10000
Dim u(g) As Double
Dim d1(g) As Double
Dim e, o, v, q As Double
dMAX = 0.0015
Dim z(100000, n * 2 + 1) As Double
For i = 0 To 100000
For j = 1 To n * 2 + 1
If j < n * 2 + 1 Then
z(i, j) = 0
Else
z(i, n * 2 + 1) = dMAX
End If
Next j
Next i
e = 0.001
r = 0
v = 1
Do While dMAX > e
o = 0
For i = 1 To n
o = o + 1
For j = 1 To n
If (i < j Or i > j) Then
k(i, i) = k(i, j) * z(i - 1, j) + r
r = k(i, i)
End If
Next j
k(i, i) = k(i, i) + k(i, m)
z(v, o) = k(i, i)
Next i
o = 0
q = 1
For j = n + 1 To 2 * n
z(v, j) = Math.Abs(z(v, q) - z(v - 1, q))
q = q + 1
If dMAX < z(v, j) Then
dMAX = z(v, j)
End If
Next j
z(v, n * 2 + 1) = dMAX
v = v + 1
Loop
Console.WriteLine("{0}", dMAX)
For i = 1 To n
Console.Write("X{0}= {1} ", i, z(i, j))
Next i
Console.ReadLine()
End Sub
End Module