package com.company; import java.sql.Time; import java.text.DecimalFormat; import java.util.Calendar; import java.util.Date; import java.util.Scanner; public class Main { public static void main(String[] args) { // write your code here Scanner sc=new Scanner(System.in); int start=sc.nextInt(); int end=sc.nextInt(); int a=start/100; int b=start%100; int c=end/100; int d=end%100; int x,y; DecimalFormat df=new DecimalFormat("00"); if(b<=d){ x=d-b; y=c-a; }else{ x=d+60-b; y=c-a-1; } System.out.println(df.format(y)+":"+df.format(x)); } }
缺少分析,找方法找半天,還不如自己組裝,此題百度過。