Изменение кода с С++ на Visual Basic - VB
Формулировка задачи:
Кто шарит в этом могут перевести в Visual Basic 6????
Решение задачи: «Изменение кода с С++ на Visual Basic»
textual
Листинг программы
Option Explicit Option Base 0 Function main() As Long Dim n As Long Dim i As Long Dim j As Long Dim k As Long Dim max As Long Open "in.txt" For Input As #1 Open "out.txt" For Output As #2 Input #1, n Dim matrix() As Double ReDim matrix(n - 1, n - 1) Dim x() As Double ReDim x(n - 1) Dim r As Double For i = 0 To n - 1 For j = 0 To n - 1 Input #1, matrix(i, j) Next Next For i = 0 To n - 1 'Початок max = i For j = i + 1 To n - 1 If Abs(matrix(j, i)) > Abs(matrix(max, i)) Then max = j Next If max <> i Then r = matrix(i) matrix(i) = matrix(max) matrix(max) = r End If If matrix(i, i) = 0 Then Write #2, "Sustema nevuznachena!!!" Close #1 Close #2 Exit Function End If 'Кiнець For j = n To i Step -1 matrix(i, j) = matrix(i, j) / matrix(i, i) Next For j = i + 1 To n - 1 For k = n To i Step -1 matrix(j, k) = matrix(j, k) - matrix(j, i) * matrix(i, k) Next Next Next '*Вывод треугольной матрицы 'For i = 0 To n - 1 ' For j = 0 To n - 1 ' Write #2, matrix(i, j) ' Next ' Write #2, vbLf 'Next 'Write #2, vbLf For i = n - 1 To 0 Step -1 x(i) = matrix(i, n) For j = n - 1 To i + 1 Step -1 x(i) = x(i) - x(j) * matrix(i, j) Next Next For i = 0 To n - 1 Write #2, "x" & CStr(i + 1) & "="; CStr(x(i)) & vbLf Next Close #1 Close #2 main = 0 End Function
ИИ поможет Вам:
- решить любую задачу по программированию
- объяснить код
- расставить комментарии в коде
- и т.д