Browse Source

17.10.2018

TestMethods
parent
commit
c11310995e
  1. BIN
      .vs/comivoyar/v15/.suo
  2. BIN
      .vs/comivoyar/v15/Server/sqlite3/storage.ide-shm
  3. BIN
      .vs/comivoyar/v15/Server/sqlite3/storage.ide-wal
  4. 88
      comivoyar/Program.cs
  5. BIN
      comivoyar/bin/Debug/comivoyar.exe
  6. BIN
      comivoyar/bin/Debug/comivoyar.pdb
  7. 5
      comivoyar/bin/Debug/coord.txt
  8. 2
      comivoyar/obj/Debug/comivoyar.csproj.CoreCompileInputs.cache
  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-shm

Binary file not shown.

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

Binary file not shown.

88
comivoyar/Program.cs

@ -20,31 +20,23 @@ namespace komvo
{ {
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]) });
WriteLine(str[0] + " " + str[1]);
} }
} }
WriteLine();
int matr = Points.Count; int matr = Points.Count;
double[,] Matrix = new double[matr, matr]; double[,] Matrix = new double[matr, matr];
foreach (Point p in Points)
{
WriteLine("{0} {1}", p.X, p.Y);
}
WriteLine();
for (int i = 0; i < Points.Count; i++) for (int i = 0; i < Points.Count; i++)
{ {
for (int j = i; j < Points.Count - 1; j++) for (int j = i; j < Points.Count - 1; j++)
{ {
Matrix[i, j + 1] = Math.Sqrt(Math.Pow(Points[j + 1].X - Points[i].X, 2) + Math.Pow(Points[j + 1].Y - Points[i].Y, 2)); Matrix[i, j + 1] = Matrix[j + 1, i] =
Write("{0} {1} : {2:N2}\t", Points[i].X, Points[j + 1].X, Matrix[i, j]); Math.Sqrt(Math.Pow(Points[j + 1].X - Points[i].X, 2) + Math.Pow(Points[j + 1].Y - Points[i].Y, 2));
} }
WriteLine();
} }
for (int i = 0; i < matr; i++) for (int i = 0; i < matr; i++)
{ {
for (int j = 0; j < matr; j++) Write("{0:00.00} ", Matrix[i, j]); for (int j = 0; j < matr; j++) Write("{0:00.00} ", Matrix[i, j]);
@ -54,16 +46,14 @@ namespace komvo
string formP = 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();
WriteLine("{0} {1}", formP, Fact(Points.Count - 1)); int fct = Fact(Points.Count - 1);
WriteLine("{0} {1}", formP, fct);
WriteLine("\n\n"); WriteLine("\n\n");
int[] routes = new int[Fact(Points.Count - 1)]; int[] routes = new int[fct];
double[] leng = new double[Fact(Points.Count - 1)]; double[] leng = new double[fct];
int waves = 0; int waves = fct / 6;
if (Points.Count == 4) waves = 1;
else if (Points.Count == 5) waves = 4;
else if (Points.Count == 6) waves = 20;
int cn = 1, cn2 = 0; int cn = 1, cn2 = 0;
string inf = formP; string inf = formP;
@ -125,42 +115,9 @@ namespace komvo
//} //}
//cn++; //cn++;
} }
//routes[0] = int.Parse(formP);
//routes[1] = int.Parse(Swap(formP, 1, 2));
//routes[2] = int.Parse(formP = Swap(formP, 0, 1));
//routes[3] = int.Parse(Swap(formP, 1, 2));
//routes[4] = int.Parse(formP = Swap(formP, 0, 2));
//routes[5] = int.Parse(Swap(formP, 1, 2));
} }
CountLen(ref leng, Matrix, routes);
for (int i = 0; i < routes.Length; i++)
{
double res = 0;
char[] ch = routes[i].ToString().ToCharArray();
for(int j = 0; j < ch.Length; j++)
{
if (j == 0) res += Matrix[0, 1];
else if (j == ch.Length - 1)
{
res += Matrix[int.Parse(ch[j - 1].ToString()) - 1, int.Parse(ch[j].ToString()) - 1];
res += Matrix[0, int.Parse(ch[j].ToString()) - 1];
}
else
{
res += Matrix[int.Parse(ch[j - 1].ToString()) - 1, int.Parse(ch[j].ToString()) - 1];
}
}
leng[i] = res;
}
double optim = leng[0]; double optim = leng[0];
int oIndex = 0; int oIndex = 0;
@ -181,7 +138,7 @@ namespace komvo
if (routes[i].Equals(routes[j])) WriteLine("{0} {2}:: {1} {3}!!!!", routes[i], routes[j], i, 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}", WriteLine("\n\n1{1}1 - оптимальный маршрут длинной {0:00.00}\nВсего маршрутов {2}\n{4} {3}",
optim, routes[oIndex], routes.Length, Fact(Points.Count - 1), Points.Count); optim, routes[oIndex], routes.Length, fct, Points.Count);
@ -217,6 +174,29 @@ namespace komvo
} }
public static void CountLen (ref double[] result, double[,] mtr, int[] rts)
{
for (int i = 0; i < rts.Length; i++)
{
double res = 0;
char[] ch = rts[i].ToString().ToCharArray();
for (int j = 0; j < ch.Length; j++)
{
if (j == 0) res += mtr[0, int.Parse(ch[j].ToString()) - 1];
else if (j == ch.Length - 1)
{
res += mtr[int.Parse(ch[j - 1].ToString()) - 1, int.Parse(ch[j].ToString()) - 1];
res += mtr[0, int.Parse(ch[j].ToString()) - 1];
}
else
{
res += mtr[int.Parse(ch[j - 1].ToString()) - 1, int.Parse(ch[j].ToString()) - 1];
}
}
result[i] = res;
}
}
public partial struct Point public partial struct Point
{ {
public int X { get; set; } public int X { get; set; }

BIN
comivoyar/bin/Debug/comivoyar.exe

Binary file not shown.

BIN
comivoyar/bin/Debug/comivoyar.pdb

Binary file not shown.

5
comivoyar/bin/Debug/coord.txt

@ -1,5 +1,4 @@
0 0 0 0
0 20
20 20 20 20
30 30 20 0
40 40
50 50

2
comivoyar/obj/Debug/comivoyar.csproj.CoreCompileInputs.cache

@ -1 +1 @@
a325577e7d0bb098d5c8871f5acaa6c0c34b21c6 6eed873852f8ce9c50ebe974dac1f20cc4ef270e

BIN
comivoyar/obj/Debug/comivoyar.exe

Binary file not shown.

BIN
comivoyar/obj/Debug/comivoyar.pdb

Binary file not shown.
Loading…
Cancel
Save