Program.cs 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. using System;
  2. using System.CodeDom;
  3. using System.Collections.Generic;
  4. using System.Threading.Tasks;
  5. using System.Windows.Markup;
  6. namespace TravMerchant
  7. {
  8. internal class Program
  9. {
  10. static void Main()
  11. {
  12. var table = new int?[,] {
  13. { null, 20, 18, 12, 8 },
  14. { 5, null, 14, 7, 11 },
  15. { 12, 18, null, 6, 11 },
  16. { 11, 17, 11, null, 12 },
  17. { 5, 5, 5, 5, null },
  18. };
  19. var matrix = new ReducableMatrix(table);
  20. SolutionNode node = new SolutionNode(matrix);
  21. var pathPoints = node.Solve();
  22. int[] path = new int[pathPoints.Count];
  23. path[0] = 0;
  24. for (int i = 1; i < path.Length; i++)
  25. {
  26. path[i] = pathPoints.Find(point => point.Item1 == path[i - 1]).Item2;
  27. }
  28. for (int i = 0; i < path.Length; i++)
  29. {
  30. Console.Write($"{(char)('A' + path[i])} -> ");
  31. }
  32. Console.WriteLine('A');
  33. Console.ReadKey();
  34. }
  35. }
  36. }