Advertisement
coapk

Untitled

Mar 20th, 2016
679
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.73 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3.  
  4. class OnTimeForTheExam
  5. {
  6.     static void Main()
  7.     {
  8.         int h = int.Parse(Console.ReadLine());
  9.         int m = int.Parse(Console.ReadLine());
  10.         int hourArrive = int.Parse(Console.ReadLine());
  11.         int minuteArrive = int.Parse(Console.ReadLine());
  12.  
  13.         if (h == hourArrive)
  14.         {
  15.             if (m == minuteArrive)
  16.             {
  17.                 Console.WriteLine("On time"); return;
  18.             }
  19.             else if (m > minuteArrive)
  20.             {
  21.                 if (Math.Abs(m - minuteArrive) <= 30)
  22.                 {
  23.                     Console.WriteLine("On time");
  24.                     Console.WriteLine("{0} minutes before before the start", Math.Abs(m - minuteArrive)); return;
  25.                 }
  26.                 else
  27.                 {
  28.                     Console.WriteLine("Early");
  29.                     Console.WriteLine("{0} minutes before before the start", Math.Abs(m - minuteArrive)); return;
  30.                 }
  31.             }
  32.             else
  33.             {
  34.                 Console.WriteLine("Late");
  35.                 Console.WriteLine("{0} minutes after the start", Math.Abs(m - minuteArrive)); return;
  36.             }
  37.         }
  38.  
  39.         else if (hourArrive > h)
  40.         {
  41.             if (((hourArrive * 60 + minuteArrive) - (h * 60 + m)) < 60)
  42.             {
  43.                 Console.WriteLine("Late");
  44.                 Console.WriteLine("{0} minutes after the start", (hourArrive * 60 + minuteArrive) - (h * 60 + m)); return;
  45.             }
  46.             else
  47.             {
  48.                 Console.WriteLine("Late");
  49.                 Console.WriteLine("{0}:{1:00} hours after the start", hourArrive - h, Math.Abs(m - minuteArrive)); return;
  50.             }
  51.         }
  52.  
  53.         else
  54.         {
  55.             if (h - hourArrive == 1)
  56.             {
  57.                 if (60 - minuteArrive + m <= 30)
  58.                 {
  59.                     Console.WriteLine("On time");
  60.                     Console.WriteLine("{0} minutes before the start", 60 - minuteArrive); return;
  61.                 }
  62.                 else
  63.                 {
  64.                     Console.WriteLine("Early");
  65.                     if (m == minuteArrive)
  66.                     {
  67.                         Console.WriteLine("{0}:00 hours before the start", Math.Abs(h - hourArrive));
  68.                         return;
  69.                     }
  70.                     Console.WriteLine("{0} minutes before the start", 60 - minuteArrive + m);
  71.                 }
  72.             }
  73.             else
  74.             {
  75.                 Console.WriteLine("Early");
  76.                 Console.WriteLine("{0}:{1:00} hours before the start", Math.Abs(hourArrive - h), Math.Abs(minuteArrive - m));
  77.             }
  78.         }
  79.     }
  80. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement