Beispiel #1
0
 IEnumerable <ProblemData> ReadData()
 {
     using (var stream = File.OpenText(DataFileName + ".in"))
     {
         var linenum = int.Parse(stream.ReadLine());
         for (int index = 0; index < linenum; index++)
         {
             yield return(ProblemData.Parse(stream.ReadLine()));
         }
     }
 }
Beispiel #2
0
        public void SolveAndWrite()
        {
            var dataList = ReadData();

            ProblemData.InitData();
            var resultList = dataList.Select(d => d.Calc());

            using (var stream = File.CreateText(DataFileName + ".out"))
            {
                int count = 1;
                foreach (var result in resultList)
                {
                    stream.WriteLine("Case #{0}: {1}", count, result);
                    count++;
                }
            }
        }