задачата за 'Навреме за изпит'
Имали някой решението на тази задача?
Имали някой решението на тази задача?
Здравей. Пробвай това решение ще сработи ли
static void Main(string[] args)
{
int hourExam = int.Parse(Console.ReadLine());
int minuteExam = int.Parse(Console.ReadLine());
int incomingHour = int.Parse(Console.ReadLine());
int incomingMinute = int.Parse(Console.ReadLine());
int examTotalMinuets = hourExam * 60 + minuteExam;
int incomeTotalMinutes = incomingHour * 60 + incomingMinute;
int timeDifference = examTotalMinuets - incomeTotalMinutes;
if (timeDifference < 0)
{
Console.WriteLine("Late");
int timeAbsolute = Math.Abs(timeDifference);
if (timeAbsolute < 60)
{
PrintMinutes(timeAbsolute, false);
}
else
{
PrintHours(timeAbsolute, false);
}
}
else if (timeDifference > 30)
{
Console.WriteLine("Early");
if (timeDifference < 60)
{
PrintMinutes(timeDifference);
}
else
{
PrintHours(timeDifference);
}
}
else
{
Console.WriteLine("On Time");
if (timeDifference > 0)
{
PrintMinutes(timeDifference);
}
}
}
private static void PrintHours(int time, bool before = true)
{
int hour = time / 60;
int minute = time % 60;
if (before)
{
Console.WriteLine($"{hour}:{minute:D2} hours before the start");
}
else
{
Console.WriteLine($"{hour}:{minute:D2} hours after the start");
}
}
private static void PrintMinutes(int time, bool before = true)
{
if (before)
{
Console.WriteLine($"{time} minutes before the start");
}
else
{
Console.WriteLine($"{time} minutes after the start");
}
}