시간 분을 입력후 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;
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;
}
}
}
}
}
|
'Console(콘솔) > 실습' 카테고리의 다른 글
Switch 문 연습(19.09.26) (0) | 2019.09.26 |
---|---|
정수를 입력 받아3 와 5로 나누어 최소 몫을 구하기(19.09.25) (0) | 2019.09.25 |
최대 공약수 구하기(19.09.24) (0) | 2019.09.24 |
배수 참/거짓 (19.09.24) (0) | 2019.09.24 |
두번째로 큰 정수가 누구인가 (19.09.24) (0) | 2019.09.24 |