12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455 |
- package CSP.temp.A1;
- import java.util.Scanner;
- /**
- * @Projectname: LeetCode
- * @Filename: CSP.temp.A1.CSP.temp.A2.CSP.temp.A3.CSP.temp.A4.CSP.temp.A5.Main
- * @Author: 杨逸
- * @Data:2023/9/2 13:27
- * @Description: U189818 时间间隔
- */
- public class Main {
- private final static Scanner input = new Scanner(System.in);
- private static int h1;
- private static int m1;
- private static int s1;
- private static int h2;
- private static int m2;
- private static int s2;
- public static void main(String[] args) {
- h1 = input.nextInt();
- m1 = input.nextInt();
- s1 = input.nextInt();
- h2 = input.nextInt();
- m2 = input.nextInt();
- s2 = input.nextInt();
- int result = 0;
- //秒差
- if (s2 >= s1){
- result +=s2-s1;
- }else{
- //借位
- result += s2-s1+60;
- if (m2>0){
- m2--;
- }else{
- h2--;
- m2 += 60;
- m2 --;
- }
- }
- //分钟差
- if (m2 >=m1){
- result += (m2-m1)*60;
- }else{
- //借位
- result += (m2-m1+60)*60;
- h2--;
- }
- //小时差
- result += (h2-h1)*3600;
- System.out.println(result);
- }
- }
|