Added simple algorithm
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
|
||||
@@ -20,10 +21,33 @@ namespace TMI_practicum
|
||||
Console.WriteLine("File {0} not found.", args[0]);
|
||||
Environment.Exit(1);
|
||||
}
|
||||
|
||||
var parsed = ParseFile(args[0]);
|
||||
|
||||
IEnumerable<Intersection> solved;
|
||||
|
||||
Stopwatch stopwatch = new Stopwatch();
|
||||
stopwatch.Start();
|
||||
|
||||
switch (parsed.Item1)
|
||||
{
|
||||
case 1:
|
||||
solved = SimpleAlgorithm.Solve(parsed.Item3);
|
||||
break;
|
||||
case 2:
|
||||
throw new NotImplementedException();
|
||||
case 3:
|
||||
throw new NotImplementedException();
|
||||
default:
|
||||
throw new ArgumentException("Algorithm with id: " + parsed.Item1 + " is not defined!");
|
||||
}
|
||||
|
||||
stopwatch.Stop();
|
||||
WriteOutput(solved, stopwatch.ElapsedMilliseconds / 1000.0);
|
||||
}
|
||||
|
||||
|
||||
private static Tuple<byte, int, ICollection<Circle>> ParseFile(string path)
|
||||
private static Tuple<byte, int, IList<Circle>> ParseFile(string path)
|
||||
{
|
||||
|
||||
byte algoritm = 0;
|
||||
@@ -52,10 +76,10 @@ namespace TMI_practicum
|
||||
}
|
||||
}
|
||||
|
||||
return new Tuple<byte, int, ICollection<Circle>>(algoritm, nbCircles, circles);
|
||||
return new Tuple<byte, int, IList<Circle>>(algoritm, nbCircles, circles);
|
||||
}
|
||||
|
||||
private static readonly string OutputFile = "output.txt";
|
||||
private const string OutputFile = "output.txt";
|
||||
|
||||
private static void WriteOutput(IEnumerable<Intersection> intersections, double time)
|
||||
{
|
||||
@@ -70,34 +94,9 @@ namespace TMI_practicum
|
||||
{
|
||||
sw.WriteLine("{0}\t{1}", intersection.X, intersection.Y);
|
||||
}
|
||||
|
||||
sw.WriteLine("\r\n{0}", time);
|
||||
}
|
||||
}
|
||||
|
||||
private struct Circle
|
||||
{
|
||||
public readonly double X;
|
||||
public readonly double Y;
|
||||
public readonly double R;
|
||||
|
||||
public Circle(double x, double y, double r)
|
||||
{
|
||||
X = x;
|
||||
Y = y;
|
||||
R = r;
|
||||
}
|
||||
}
|
||||
|
||||
private struct Intersection
|
||||
{
|
||||
public readonly double X;
|
||||
public readonly double Y;
|
||||
|
||||
public Intersection(double x, double y)
|
||||
{
|
||||
X = x;
|
||||
Y = y;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user