diff --git a/.vs/comivoyar/v15/.suo b/.vs/comivoyar/v15/.suo index 23797c2..503d6b1 100644 Binary files a/.vs/comivoyar/v15/.suo and b/.vs/comivoyar/v15/.suo differ diff --git a/.vs/comivoyar/v15/Server/sqlite3/storage.ide b/.vs/comivoyar/v15/Server/sqlite3/storage.ide index 79307ff..3be0b8b 100644 Binary files a/.vs/comivoyar/v15/Server/sqlite3/storage.ide and b/.vs/comivoyar/v15/Server/sqlite3/storage.ide differ diff --git a/.vs/comivoyar/v15/Server/sqlite3/storage.ide-shm b/.vs/comivoyar/v15/Server/sqlite3/storage.ide-shm index bece3a3..7d56999 100644 Binary files a/.vs/comivoyar/v15/Server/sqlite3/storage.ide-shm and b/.vs/comivoyar/v15/Server/sqlite3/storage.ide-shm differ diff --git a/.vs/comivoyar/v15/Server/sqlite3/storage.ide-wal b/.vs/comivoyar/v15/Server/sqlite3/storage.ide-wal index 30e667d..d9f76e0 100644 Binary files a/.vs/comivoyar/v15/Server/sqlite3/storage.ide-wal and b/.vs/comivoyar/v15/Server/sqlite3/storage.ide-wal differ diff --git a/comivoyar/Program.cs b/comivoyar/Program.cs index 3a9e2cc..1236ac0 100644 --- a/comivoyar/Program.cs +++ b/comivoyar/Program.cs @@ -1,8 +1,5 @@ using System; using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; using System.IO; using static System.Console; @@ -10,7 +7,7 @@ namespace komvo { class Program { - public static List Points = new List(); + public static List Points = new List(); static void Main(string[] args) { @@ -22,7 +19,7 @@ namespace komvo while ((line = cr.ReadLine()) != null) { 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]; - foreach (point p in Points) + foreach (Point p in Points) { WriteLine("{0} {1}", p.X, p.Y); } @@ -54,12 +51,10 @@ namespace komvo 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 = 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"); 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 == 6) waves = 20; - + int cn = 0, cn2 = 0; 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++) { - if (i == 0 && j == 0) routes[j + i * 6] = int.Parse(formP); - else if (j % 2 == 0) routes[j + i * 6] = int.Parse(formP = Swap(formP, 0, j / 2)); - else routes[j + i * 6] = int.Parse(Swap(formP, 1, 2)); + if (i == 0 && j == 0) routes[j + (i - 1) * 6] = int.Parse(formP); + else if (j % 2 == 0) routes[j + (i - 1) * 6] = int.Parse(formP = Swap(formP, 0, j / 2)); + else routes[j + (i - 1) * 6] = int.Parse(Swap(formP, 1, 2)); } - if (waves > 1) formP = Swap(inf, 0, 3); + + + 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++; + } @@ -92,18 +118,6 @@ namespace komvo //routes[4] = int.Parse(formP = Swap(formP, 0, 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]; } - } leng[i] = res; } @@ -135,14 +148,22 @@ namespace komvo int oIndex = 0; 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]) { optim = leng[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 Y { get; set; } diff --git a/comivoyar/bin/Debug/comivoyar.exe b/comivoyar/bin/Debug/comivoyar.exe index 7406ac1..78cdbba 100644 Binary files a/comivoyar/bin/Debug/comivoyar.exe and b/comivoyar/bin/Debug/comivoyar.exe differ diff --git a/comivoyar/bin/Debug/comivoyar.pdb b/comivoyar/bin/Debug/comivoyar.pdb index 5ecd370..066940a 100644 Binary files a/comivoyar/bin/Debug/comivoyar.pdb and b/comivoyar/bin/Debug/comivoyar.pdb differ diff --git a/comivoyar/bin/Debug/coord.txt b/comivoyar/bin/Debug/coord.txt index 3e08df8..e0bcba9 100644 --- a/comivoyar/bin/Debug/coord.txt +++ b/comivoyar/bin/Debug/coord.txt @@ -1,5 +1,5 @@ -30 40 -20 50 -10 23 -35 32 -25 25 \ No newline at end of file +10 10 +20 20 +30 30 +40 40 +50 50 \ No newline at end of file diff --git a/comivoyar/obj/Debug/comivoyar.exe b/comivoyar/obj/Debug/comivoyar.exe index 7406ac1..78cdbba 100644 Binary files a/comivoyar/obj/Debug/comivoyar.exe and b/comivoyar/obj/Debug/comivoyar.exe differ diff --git a/comivoyar/obj/Debug/comivoyar.pdb b/comivoyar/obj/Debug/comivoyar.pdb index 5ecd370..066940a 100644 Binary files a/comivoyar/obj/Debug/comivoyar.pdb and b/comivoyar/obj/Debug/comivoyar.pdb differ