예제 #1
0
    static void Main()
    {
        string line;

        while ((line = Console.ReadLine()) != null && line != "")
        {
            if (line.Length < 11)
            {
                line = Console.ReadLine();
            }
            int  pushes    = 0;
            time startTime = new time(-1, -1, -1, "MM");
            time endTime   = new time(-1, -1, -1, "MM");

            startTime.setHour(line[0] - '0');
            startTime.setM1(line[2] - '0');
            startTime.setM2(line[3] - '0');
            startTime.setAp(line[4].ToString() + "m");

            endTime.setHour(line[7] - '0');
            endTime.setM1(line[9] - '0');
            endTime.setM2(line[10] - '0');
            endTime.setAp(line[11].ToString() + "m");

            int hDif = Math.Abs(startTime.getHour() - endTime.getHour());
            pushes += Math.Min(hDif, 12 - hDif);

            int m1Dif = Math.Abs(startTime.getM1() - endTime.getM1());
            pushes += Math.Min(m1Dif, 6 - m1Dif);

            int m2Dif = Math.Abs(startTime.getM2() - endTime.getM2());
            pushes += Math.Min(m2Dif, 10 - m2Dif);

            if (!string.Equals(startTime.getAp(), endTime.getAp()))
            {
                pushes += 1;
            }

            if (pushes == 1)
            {
                Console.Write("Going from " + startTime.display() + " to " + endTime.display() + " requires " + pushes + " push\n");
            }
            else
            {
                Console.Write("Going from " + startTime.display() + " to " + endTime.display() + " requires " + pushes + " pushes\n");
            }
        }
    }
예제 #2
0
        static void Main(string[] args)
        {
            DateTime currenttime = DateTime.Now;
            time     t           = new time(currenttime);

            t.display();
            int thehour;
            int theminute;
            int thesecond;

            t.gettime(out thehour, out theminute, out thesecond);
            Console.WriteLine("current time : {0}:{1}:{2}", thehour, theminute, thesecond);
            Console.ReadLine();
        }