남영운 :: 시간 분을 입력후 45분을 빼기(19.09.25)

시간 분을 입력후 45분을 빼기(19.09.25)

Console(콘솔)/실습 2019. 9. 25. 12:45
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
 
namespace Syntax09
{
    class Program
    {
        static void Main(string[] args)
        {
            
            for (; ; ) {
            int H = int.Parse(Console.ReadLine());
            int M = int.Parse(Console.ReadLine());
                if (0 <= H && H <= 23 && 0 <= M && M <= 59)
                {
                    if ((M - 45>= 0)
                    {
                        M = M - 45;
                        Console.WriteLine($"{H} {M}");
                    }
                    else if ((M - 45< 0)
                    {
                        H = H - 1;
                        M = 60 + (M - 45);
                        if (H < 0)
                        {
                            H = 23;
                            Console.WriteLine($"{H} {M}");
                        }
                        else if (H >= 0)
                        {
                            Console.WriteLine($"{H} {M}");
                        }
                    }
                }
                else
                {
                    Console.WriteLine("다시 입력");
                    continue;
                }
            }
        }
    }
}
 
 
 
: