static void Main(string[] args) { var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = true }; Console.SetOut(sw); Console.WriteLine("Input a number:"); var numStr = Console.ReadLine(); BigInteger num; if (BigInteger.TryParse(numStr, out num)) { var experimentE = new Experiment(new FibonacciExecutor(new Core.FibonacciEfficient(), num), logStreamWriter: new StreamWriter(Console.OpenStandardOutput()), new StreamWriter(Console.OpenStandardOutput())); experimentE.Start(); while (experimentE.Now == Experiment.State.Running) { Thread.Sleep(500); } return; } Console.WriteLine("[Error] Please input a number."); }
public IActionResult Result() { ViewBag.Message = ""; if (_experiment != null) { ViewBag.Message += _experiment.Now switch { Experiment.State.Init => $"Experiment is Initializing...\n", Experiment.State.Running => $"Experiment is still running...\n", Experiment.State.Error => $"Experiment is timeout.\n", Experiment.State.Finished => "", _ => throw new Exception("No state found") }; if (ViewBag.Message == "") { ViewBag.DataListStr = String.Join(',', _pointSet.Select(p => $"[{p.x},{p.y}]").ToList()); if (_experiment.Executor is ClosestPairOfPointsExecutor cpopExec) { ViewBag.Distance = cpopExec.Distance; ViewBag.PointPairStr = $"[{cpopExec.BestPairs[0].Item1.x},{cpopExec.BestPairs[0].Item1.y}]," + $"[{cpopExec.BestPairs[0].Item2.x},{cpopExec.BestPairs[0].Item2.y}]"; } } } else { if (_pointSet.Count < 2) { ViewBag.Message += $"Points less than 2!\n"; } else { _experiment = new Experiment( new ClosestPairOfPointsExecutor(new ClosestPairOfPointsEfficient(), _pointSet) ); _experiment.Start(); return(RedirectToAction("Result")); } } return(View()); }