Advertisement
YavorGrancharov

Sino_The_Walker(60%)

Jul 16th, 2017
142
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.72 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4.  
  5. namespace Sino_The_Walker
  6. {
  7.     class Program
  8.     {
  9.         static void Main(string[] args)
  10.         {
  11.             int[] arr = Console.ReadLine().Split(':').Select(int.Parse).ToArray();
  12.             var steps = int.Parse(Console.ReadLine()) % 86400;
  13.             var oneStepTime = int.Parse(Console.ReadLine()) % 86400;
  14.  
  15.             var hours = arr[0];
  16.             var minutes = arr[1];
  17.             var seconds = arr[2];
  18.  
  19.             var stepsHours = ((steps * oneStepTime) / 60) / 60;
  20.             var stepsMinutes = (steps * oneStepTime) / 60;
  21.             var stepsSeconds = (steps * oneStepTime) % 60;
  22.  
  23.             var totalHours = hours + stepsHours;
  24.             var totalMinutes = minutes + stepsMinutes;
  25.             var totalSeconds = seconds + stepsSeconds;
  26.  
  27.             for (int i = 0; i < arr.Length; i++)
  28.             {
  29.                 if (totalSeconds > 59)
  30.                 {
  31.                     totalMinutes += 1;
  32.                     totalSeconds -= 60;
  33.                 }
  34.                 if (totalMinutes > 59)
  35.                 {
  36.                     totalHours += 1;
  37.                     totalMinutes -= 60;
  38.                 }
  39.                 if (totalHours > 23)
  40.                 {
  41.                     totalHours = 0;
  42.                 }
  43.             }
  44.  
  45.             if (totalHours < 10 || totalMinutes < 10 || totalSeconds < 10)
  46.             {
  47.                 Console.WriteLine("Time Arrival: {0:D2}:{1:D2}:{2:D2}", totalHours, totalMinutes, totalSeconds);
  48.             }
  49.             else
  50.             {
  51.                 Console.WriteLine("Time Arrival: {0}:{1}:{2}", totalHours, totalMinutes, totalSeconds);
  52.             }
  53.         }
  54.     }
  55. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement