-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathnatrij.java
51 lines (35 loc) · 1.04 KB
/
natrij.java
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
49
50
51
import java.util.Scanner;
public class natrij {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
String line1 = scan.nextLine();
String line2 = scan.nextLine();
String[] h1 = line1.split(":");
String[] h2 = line2.split(":");
if(Integer.valueOf(h2[0]) <= Integer.valueOf(h1[0]))
h2[0] = Integer.valueOf(h2[0]) + 24 + "";
int s1 = Integer.valueOf(h1[0]) * 3600 + Integer.valueOf(h1[1]) * 60 + Integer.valueOf(h1[2]);
int s2 = Integer.valueOf(h2[0]) * 3600 + Integer.valueOf(h2[1]) * 60 + Integer.valueOf(h2[2]);
s2 -= s1;
int h = s2 / 3600;
s2 %= 3600;
int m = s2 / 60;
s2 %= 60;
int s = s2;
if(h < 10)
System.out.print("0" + h + "");
else
System.out.print(h + "");
System.out.print(":");
if(m < 10)
System.out.print("0" + m + "");
else
System.out.print(m + "");
System.out.print(":");
if(s < 10)
System.out.print("0" + s + "");
else
System.out.print(s + "");
scan.close();
}
}