Browse Source

Исправить при 6 повторы

TestMethods
parent
commit
cf84c4996a
  1. BIN
      .vs/comivoyar/v15/.suo
  2. BIN
      .vs/comivoyar/v15/Server/sqlite3/storage.ide
  3. BIN
      .vs/comivoyar/v15/Server/sqlite3/storage.ide-shm
  4. BIN
      .vs/comivoyar/v15/Server/sqlite3/storage.ide-wal
  5. 85
      comivoyar/Program.cs
  6. BIN
      comivoyar/bin/Debug/comivoyar.exe
  7. BIN
      comivoyar/bin/Debug/comivoyar.pdb
  8. 10
      comivoyar/bin/Debug/coord.txt
  9. BIN
      comivoyar/obj/Debug/comivoyar.exe
  10. BIN
      comivoyar/obj/Debug/comivoyar.pdb

BIN
.vs/comivoyar/v15/.suo

Binary file not shown.

BIN
.vs/comivoyar/v15/Server/sqlite3/storage.ide

Binary file not shown.

BIN
.vs/comivoyar/v15/Server/sqlite3/storage.ide-shm

Binary file not shown.

BIN
.vs/comivoyar/v15/Server/sqlite3/storage.ide-wal

Binary file not shown.

85
comivoyar/Program.cs

@ -1,8 +1,5 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO; using System.IO;
using static System.Console; using static System.Console;
@ -10,7 +7,7 @@ namespace komvo
{ {
class Program class Program
{ {
public static List<point> Points = new List<point>(); public static List<Point> Points = new List<Point>();
static void Main(string[] args) static void Main(string[] args)
{ {
@ -22,7 +19,7 @@ namespace komvo
while ((line = cr.ReadLine()) != null) while ((line = cr.ReadLine()) != null)
{ {
string[] str = line.Split(); string[] str = line.Split();
Points.Add(new point { X = int.Parse(str[0]), Y = int.Parse(str[1]) }); Points.Add(new Point { X = int.Parse(str[0]), Y = int.Parse(str[1]) });
} }
} }
@ -30,7 +27,7 @@ namespace komvo
double[,] Matrix = new double[matr, matr]; double[,] Matrix = new double[matr, matr];
foreach (point p in Points) foreach (Point p in Points)
{ {
WriteLine("{0} {1}", p.X, p.Y); WriteLine("{0} {1}", p.X, p.Y);
} }
@ -54,12 +51,10 @@ namespace komvo
WriteLine(); WriteLine();
} }
string formP = string.Empty, formN = string.Empty; string formP = string.Empty;
for (int i = 2; i <= Points.Count; i++) formP += i.ToString(); for (int i = 2; i <= Points.Count; i++) formP += i.ToString();
for (int i = Points.Count; i >= 2; i--) formN += i.ToString();
WriteLine("{0} {1} {2}", formP, formN, Fact(Points.Count - 1));
WriteLine(formP + " " + Swap(formP, 1, 2)); WriteLine("{0} {1}", formP, Fact(Points.Count - 1));
WriteLine("\n\n"); WriteLine("\n\n");
int[] routes = new int[Fact(Points.Count - 1)]; int[] routes = new int[Fact(Points.Count - 1)];
@ -70,17 +65,48 @@ namespace komvo
else if (Points.Count == 5) waves = 4; else if (Points.Count == 5) waves = 4;
else if (Points.Count == 6) waves = 20; else if (Points.Count == 6) waves = 20;
int cn = 0, cn2 = 0;
string inf = formP; string inf = formP;
for (int i = 0; i < waves; i++) for (int i = 1; i < waves + 1; i++)
{ {
for(int j = 0; j < 6; j++) for(int j = 0; j < 6; j++)
{ {
if (i == 0 && j == 0) routes[j + i * 6] = int.Parse(formP); if (i == 0 && j == 0) routes[j + (i - 1) * 6] = int.Parse(formP);
else if (j % 2 == 0) routes[j + i * 6] = int.Parse(formP = Swap(formP, 0, j / 2)); else if (j % 2 == 0) routes[j + (i - 1) * 6] = int.Parse(formP = Swap(formP, 0, j / 2));
else routes[j + i * 6] = int.Parse(Swap(formP, 1, 2)); else routes[j + (i - 1) * 6] = int.Parse(Swap(formP, 1, 2));
}
if (waves > 1)
{
if (i % 5 == 0)
{
formP = Swap(inf, cn2++, 4);
WriteLine("{0} {1}", formP, inf);
}
else
{
if (cn > 2) cn = 0;
formP = Swap(inf, cn++, 3);
WriteLine("{0} {1}", formP, inf);
}
//if (cn > 4)
//{
// cn = 0;
// formP = Swap(inf, cn2, 4);
// cn2++;
//}
//else
//{
//formP = Swap(inf, cn, 3);
//}
//cn++;
} }
if (waves > 1) formP = Swap(inf, 0, 3);
@ -92,18 +118,6 @@ namespace komvo
//routes[4] = int.Parse(formP = Swap(formP, 0, 2)); //routes[4] = int.Parse(formP = Swap(formP, 0, 2));
//routes[5] = int.Parse(Swap(formP, 1, 2)); //routes[5] = int.Parse(Swap(formP, 1, 2));
//for (int i = 0; i < Points.Count; i++)
//{
// for (int j = i; j < Points.Count - 1; j++)
// {
// }
// //WriteLine();
//}
} }
@ -126,7 +140,6 @@ namespace komvo
{ {
res += Matrix[int.Parse(ch[j - 1].ToString()) - 1, int.Parse(ch[j].ToString()) - 1]; res += Matrix[int.Parse(ch[j - 1].ToString()) - 1, int.Parse(ch[j].ToString()) - 1];
} }
} }
leng[i] = res; leng[i] = res;
} }
@ -135,14 +148,22 @@ namespace komvo
int oIndex = 0; int oIndex = 0;
for (int i = 0; i < leng.Length; i++) for (int i = 0; i < leng.Length; i++)
{ {
WriteLine("{0:N2}", leng[i]); WriteLine("{0:N2} - {1}", leng[i], routes[i]);
if (optim > leng[i]) if (optim > leng[i])
{ {
optim = leng[i]; optim = leng[i];
oIndex = i; oIndex = i;
} }
} }
WriteLine("1{1}1 - оптимальный маршрут длинной {0:00.00}", optim, routes[oIndex]);
for (int i = 0; i < routes.Length; i++)
{
for (int j = i + 1; j < routes.Length - 1; j++)
if (routes[i].Equals(routes[j])) WriteLine("{0} {2}:: {1} {3}!!!!", routes[i], routes[j], i, j);
}
WriteLine("\n\n1{1}1 - оптимальный маршрут длинной {0:00.00}\nВсего маршрутов {2}\n{4} {3}",
optim, routes[oIndex], routes.Length, Fact(Points.Count - 1), Points.Count);
@ -165,7 +186,7 @@ namespace komvo
} }
public partial struct point public partial struct Point
{ {
public int X { get; set; } public int X { get; set; }
public int Y { get; set; } public int Y { get; set; }

BIN
comivoyar/bin/Debug/comivoyar.exe

Binary file not shown.

BIN
comivoyar/bin/Debug/comivoyar.pdb

Binary file not shown.

10
comivoyar/bin/Debug/coord.txt

@ -1,5 +1,5 @@
30 40 10 10
20 50 20 20
10 23 30 30
35 32 40 40
25 25 50 50

BIN
comivoyar/obj/Debug/comivoyar.exe

Binary file not shown.

BIN
comivoyar/obj/Debug/comivoyar.pdb

Binary file not shown.
Loading…
Cancel
Save