Beispiel #1
0
        public void Run(string[] args)
        {
            using (StreamReader reader = File.OpenText(args[0]))
            {
                TriangleCollection collection = new TriangleCollection();
                while (!reader.EndOfStream)
                {
                    string line = reader.ReadLine();

                    string[] values = line.Trim().Split(' ');
                    int[] row = new int[values.Length];
                    for (int i = 0; i < values.Length; i++)
                    {
                        int result = 0;
                        int length = values[i].Length;
                        for (int l = 0; l < length; l++)
                        {
                            result = 10 * result + (values[i][l] - 48);
                        }
                        row[i] = result;
                    }
                    collection.AddRow(row);
                }

                Console.WriteLine(collection.MaximumTriangleWalk());
            }
        }
Beispiel #2
0
        public void Run(string[] args)
        {
            using (StreamReader reader = File.OpenText(args[0]))
            {
                TriangleCollection collection = new TriangleCollection();
                while (!reader.EndOfStream)
                {
                    string line = reader.ReadLine();
                    if (null == line)
                        continue;
                    string[] values = line.Trim().Split(' ');
                    int[] row = new int[values.Length];
                    for (int i = 0; i < values.Length; i++)
                    {
                        row[i] = Int32.Parse(values[i]);
                    }
                    collection.AddRow(row);
                }

                Console.WriteLine(collection.MaximumTriangleWalk());
            }
        }