diff --git a/linear/Program.cs b/linear/Program.cs index 4ec40d7..cf01f76 100644 --- a/linear/Program.cs +++ b/linear/Program.cs @@ -52,8 +52,8 @@ namespace linear { Points.Add(new Point { - X = (double)matrix[i, 2] / matrix[i, 1], - Y = (double)matrix[i, 2] / matrix[i, 0], + Y = matrix[i, 2] / matrix[i, 1], + X = matrix[i, 2] / matrix[i, 0], Line = i + 1 }); if (i == 0) @@ -75,13 +75,13 @@ namespace linear foreach (Point p in Points) WriteLine("{0:00.00} {1:00.00}", p.X, p.Y); Write("\n\n"); - WriteLine("{0:0.0} {1:0.0}\n\n", xMin, yMin); - int[] indexes = new int[3]; + WriteLine("X: {0:0.0} {2} \nY: {1:0.0} {3}\n\n", xMin, yMin, indexMinX, indexMinY); + int[] indexes = new int[workCount]; if(indexMinX != indexMinY) { - indexes[0] = indexMinX - 1; - indexes[1] = indexMinY - 1; + indexes[0] = indexMinY - 1; + indexes[1] = indexMinX - 1; for (int i = 0; i < 3; i++) if (i != indexes[0] && i != indexes[1]) indexes[2] = i; @@ -99,7 +99,8 @@ namespace linear WriteLine(Points.Count + "\n\n"); - foreach (Point p in Points) WriteLine("{0} {1} {2}", p.X, p.Y, p.Line); // y = x , x =y + foreach (Point p in Points) WriteLine("{0:0.0} {1:0.0} {2}", p.X, p.Y, p.Line); + WriteLine("\n\n"); if (Points[Points.Count - 1].X < 0 || Points[Points.Count - 1].Y < 0) Points.RemoveAt(Points.Count - 1); @@ -111,15 +112,15 @@ namespace linear } else { - double tempQ = 0d; + double tempQ = 0D; for (int i= 1; i < 4; i++) { - WriteLine("{0} {1} {2}", i, Points[Points.Count - i].X, Points[Points.Count - i].Y); + WriteLine("{0} {1:0.0} {2:0.0}", i, Points[Points.Count - i].X, Points[Points.Count - i].Y); double t = Result(matrix, Points[Points.Count - i].X, Points[Points.Count - i].Y); if (tempQ < t) tempQ = t; } - WriteLine(tempQ); + WriteLine("{0:0.0}", tempQ); } @@ -142,7 +143,8 @@ namespace linear public static double Result(double[,] matrix, double x, double y) { double res; - res = matrix[3, 0] * x + matrix[3, 1]*y; + WriteLine("\t{0} * {1:0.0} + {2} * {3:0.0}", matrix[3, 0], x, matrix[3, 1], y); + res = matrix[3, 0] * x + matrix[3, 1] * y; return res; }