Program.cs 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Diagnostics;
  4. using System.IO;
  5. using System.Linq;
  6. using System.Net.Http.Headers;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9. namespace MinEl
  10. {
  11. internal class Program
  12. {
  13. static double[][] Matrix(string[] matrixString) => matrixString.Select(line=>line.Split(' ').Select(double.Parse).ToArray()).ToArray();
  14. static void Main(string[] args)
  15. {
  16. Trace.Listeners.Add(new TextWriterTraceListener("Trace and Debug.txt"));
  17. Trace.Listeners.Add(new TextWriterTraceListener(Console.Out));
  18. Trace.AutoFlush = true;
  19. string inputPath = "C:\\Users\\kkrok\\OneDrive\\Desktop\\min\\MinEl\\Input.txt";
  20. string outputPath = "output.txt";
  21. string[] allLines = File.ReadAllLines(inputPath);
  22. int separatorOne = Array.IndexOf(allLines, "-");
  23. string[] transportTaskOne = allLines.Take(separatorOne).ToArray();
  24. int separotTwoTaskOne = Array.IndexOf(transportTaskOne,"/");
  25. string[] arrayTarifstringOne = transportTaskOne.Take(separotTwoTaskOne).ToArray();
  26. double[][] arrayTarifOne = Matrix(arrayTarifstringOne);
  27. string[] suppliersAndCustomersStringOne = transportTaskOne.Skip(separotTwoTaskOne + 1).ToArray();
  28. int[][] suppliersAndCustomersOne = suppliersAndCustomersStringOne.Select(s => s.Split(' ').Select(int.Parse).ToArray()).ToArray();
  29. MinimalEl obj = new MinimalEl(arrayTarifOne, suppliersAndCustomersOne);
  30. obj.RealizationAlg();
  31. Trace.WriteLine(obj.ToString());
  32. File.WriteAllText(outputPath, obj.ToString());
  33. Console.ReadKey();
  34. }
  35. }
  36. }