Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace BackIn30Minutes
- {
- class Program
- {
- static void Main(string[] args)
- {
- int hour = int.Parse(Console.ReadLine());
- int minute = int.Parse(Console.ReadLine());
- int total = hour * 60 + minute + 30;
- int hourTotal = total / 60;
- int minuteTotal = total % 60;
- if (hourTotal > 23)
- {
- hourTotal %= 24;
- }
- if (minuteTotal > 9)
- {
- Console.WriteLine($"{hourTotal}:{minuteTotal}");
- }
- else
- {
- Console.WriteLine($"{hourTotal}:0{minuteTotal}");
- }
- }
- }
- }
- With ternary operator and ...:D2 means a decimal with two digits( 7 - 07):
- using System;
- namespace BackIn30Minutes
- {
- class Program
- {
- static void Main(string[] args)
- {
- int total = int.Parse(Console.ReadLine()) * 60 + int.Parse(Console.ReadLine()) + 30;
- Console.WriteLine($"{(total / 60 > 23? default : total / 60)}:{total % 60:D2}");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement