예제 #1
0
        static void Main(string[] args)
        {
            Graph g = new Graph();

            Console.WriteLine("===================================\n Manual Input, press key 0\n Input using File press key 1 \n\n If you press another keys, \n program is terminated .\n===================================");
            switch (Console.ReadKey().KeyChar)
            {
            case '0':
                MInput(g);
                break;

            case '1':
                if (FInput(g) == false)
                {
                    Console.ReadLine(); return;
                }
                break;

            default:
                return;
            }
            string input;

            do
            {
                Console.WriteLine("\n Please enter two cities where you want to find   \n example) Seoul Busan \n===================================\n");
                input = Console.ReadLine();
                if (input != "0")
                {
                    try
                    {
                        string[] tmp = input.Split(' ');
                        int?     t   = g.Exec(tmp[0], tmp[1]);
                        if (t == null)
                        {
                            Console.WriteLine("This input is invalid.");
                        }
                        else
                        {
                            Console.WriteLine("The time required " + (int)t + " hour(s).");
                        }
                    }catch
                    {
                        Console.WriteLine(" This input is invalid.\n");
                    }
                }
            } while (input != "0");

            Console.ReadLine();
        }