Method Itaration

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Iterations
{
class Method
{
public double[,] _Amatrix = new double[,]
{
{ 2, 2, 10 },
{ 10, 1, 1 },
{ 2, 10, 1 }
};
public double[] _Bmatrix = new double[]
{ 14, 12, 13 };
double E = 0.01;
public void prepare()
{
for (int i = 0; i < _Amatrix.GetLength(0); i++)
{
for (int j = 0; j < _Amatrix.GetLength(1); j++)
{
double sum = 0;
if (_Amatrix[i, i] != _Amatrix[i, j])
{
sum += _Amatrix[i, j];
}
if (_Amatrix[i, i] < sum)
{
for (int k = 0; k < _Amatrix.GetLength(1); k++)
{
if (_Amatrix[i, i] < _Amatrix[k, i])
{
double[] res = new double[_Amatrix.GetLength(0)];
for (int s = 0; s < _Amatrix.GetLength(0); s++)
{
res[s] = _Amatrix[k, s];
_Amatrix[k, s] = _Amatrix[i, s];
_Amatrix[i, s] = res[s];
}
}
}
}
}
}
}
}
class Program
{
static void Main(string[] args)
{
Method method = new Method();
for(int i = 0; i < method._Amatrix.GetLength(0); i++)
{
for (int j = 0; j < method._Amatrix.GetLength(1); j++)
{
Console.Write("{0} \t", method._Amatrix[i, j]);
}
Console.WriteLine();
}
method.prepare();
Console.WriteLine("\n\n");
for (int i = 0; i < method._Amatrix.GetLength(0); i++)
{
for (int j = 0; j < method._Amatrix.GetLength(1); j++)
{
Console.Write("{0} \t", method._Amatrix[i, j]);
}
Console.WriteLine();
}
Console.ReadKey();
}
}
}