Есть программа на C# которая реализует метод Жордана-Гаусса. Помогите пожалуйста, перевести код с консоли в Windows Forms. Если можете, с объяснениями, пожалуйста! Заранее спасибо!
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication1
{ class Program
{static void Main(string[] args)
{
double matrixa, matrixb, firstrowa, obernenyj, firtsrowb, secondrowa, secondrowb, lastrowa, lastrowb;
//ввод матрицы
Console.WriteLine("MatrixCount:4");
int n=4;
double[,] A = new double[,]{{2, 2, 1, 4},{3, 1, 2, 3}, {2, 1, 3, 1}};
Console.WriteLine(" (2 2 1 | 4)");
Console.WriteLine("A=(3 1 2 | 3)");
Console.WriteLine(" (2 1 3 | 1)");
//нахождение первого элемента !=0
// A[i, 0] - первый элемент строки
// k- номер строки, где первый элемент !=0
int k = 0;
for (int i = 0; i < n-1; i++)
{for (int j = 0; j < n ; j++)
{if (A[i, 0] != 0)
{ k = i;
break; }
else { Console.WriteLine("A[i, 0]=0!!!!!!!!");
break;
} } }
// замена строки с A[i,j]=0 на ненулевую
int value;
double a;
Console.WriteLine("__________zamina______");
for (int i = 0; i < n-1; i++)
{ for (int j = 0; j < n ; j++)
{if (A[i, 0] == 0)
{value = i;a = A[i, j];
A[i, j] = A[i + 1, j];
A[i + 1, j] = a;
Console.WriteLine("[{0},{1}]={2}", i, j, A[i, j]);
} } }
//
Console.WriteLine("Mass B");
Console.WriteLine("Первую строку делим на первый элемент этой строки");
double perelem=A[0, 0];
double[,] B = new double[n-1,n];
for (int i = 0; i < n-1 ; i++)
{for (int j = 0; j < n ; j++)
{firstrowa = A[0, j];
firtsrowb = B[0, j];
if (i == 0)
{
matrixb = firstrowa / perelem;
B[i, j] = matrixb;
}
if (i == 1 )
{
obernenyj = firtsrowb * A[i, 0];
B[i, j] = A[i, j] - obernenyj;
}
if (i == 2)
{
obernenyj = firtsrowb * A[i, 0];
B[i, j] = A[i, j] - obernenyj;
}
Console.WriteLine("[{0},{1}]={2}", i, j, B[i, j]); } }
double elem = B[1, 1];
Console.WriteLine("__");
for (int i = 0; i < n - 1; i++)
{
for (int j = 0; j < n; j++)
{
secondrowa = A[1, j];
secondrowb = B[1, j];
A[i, j] = B[i, j];
if (i == 1)
{
matrixa = secondrowb / elem;
A[i, j] = matrixa;
}
if (i == 2)
{
obernenyj = secondrowa * B[i, 1];
A[i, j] = B[i, j] - obernenyj;
}
Console.WriteLine("[{0},{1}]={2}", i, j, A[i, j]); } }
Console.WriteLine("Результат:");
for (int i = 0; i < n - 1; i++)
{
for (int j = 0; j < n; j++)
{
if (i == 2)
{
lastrowa = A[i, j];
B[i, j] = (lastrowa / A[2, 2]);
}
if (i == 1)
{
obernenyj = A[i + 1, j] * A[i, 2];
B[i, j] = A[i, j] - obernenyj;
}
if (i == 0)
{
obernenyj = A[i + 1, j] * A[i, 1];
B[i, j] = A[i, j] - obernenyj;
}
}
}
Console.WriteLine("x1={0}; x2={1}; x3={2}", B[0, 3], B[1, 3], B[2, 3]);
Console.WriteLine("Ответ :({0};{1};{2}).", B[0, 3], B[1, 3], B[2, 3]);
// выход
Console.WriteLine("To exit press any key.");
Console.ReadKey();
}
}
}