diff options
Diffstat (limited to 'src/Program/Program.cs')
-rw-r--r-- | src/Program/Program.cs | 33 |
1 files changed, 32 insertions, 1 deletions
diff --git a/src/Program/Program.cs b/src/Program/Program.cs index 6fddc77..9ba697b 100644 --- a/src/Program/Program.cs +++ b/src/Program/Program.cs @@ -1,2 +1,33 @@ -// See https://aka.ms/new-console-template for more information +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.IO; +namespace ClosestPair +{ + public class Program + { + public static void Main(string[] args) + { + FileInfo inputFile = (args.Length > 0) ? new FileInfo(args[0]) : new FileInfo("points1.txt"); + + if (!inputFile.Exists) { + Console.WriteLine($"Failed to open {inputFile}: File does not exist."); + return; + } + + Stopwatch stopWatch = new Stopwatch(); + stopWatch.Start(); + + PointArray points = new PointArray(inputFile.FullName); + PointPair closestPair = ClosestPair.FindClosestPair(points); + + stopWatch.Stop(); + TimeSpan ts = stopWatch.Elapsed; + + Console.WriteLine($"Closest Points: {closestPair}"); + Console.WriteLine($"Runtime: {ts.ToString("mm\\:ss\\.ff")}"); + } + } + +}
\ No newline at end of file |