Advertisement
IvetValcheva

1. Sum Seconds:

Mar 13th, 2023
475
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.06 KB | None | 0 0
  1. using System;
  2.  
  3. namespace _03.Time___15_Minutes
  4. {
  5.     class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             //1. Четем отконзолата времето на 3-мата състезатели (сек.)
  10.             int first = int.Parse(Console.ReadLine());
  11.             int second = int.Parse(Console.ReadLine());
  12.             int third = int.Parse(Console.ReadLine());
  13.  
  14.             //2. Намираме общото време в сек  
  15.             int totalTime = first + second + third;
  16.  
  17.             //3. Намираме колко минути и колко сек е общото време
  18.             int min = totalTime / 60;
  19.             int sec = totalTime % 60;
  20.  
  21.             //4. Отпечатваме резултата на конзолата (мин:сек => сек<10 => 0{сек})
  22.             if (sec<10)
  23.             {
  24.                 Console.WriteLine($"{min}:0{sec}");
  25.             }
  26.             else
  27.             {
  28.                 Console.WriteLine($"{min}:{sec}");
  29.             }
  30.         }
  31.     }
  32. }
  33.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement