代碼:
1 import java.util.*; 2 public class Main { 3 public static void main (String [] args) { 4 Scanner s=new Scanner(System.in); 5 int time1=s.nextInt(); 6 int time2=s.nextInt(); 7 int hrs,mins; 8 if(time2%100>=time1%100) { 9 mins=time2%100-time1%100; 10 hrs=time2/100-time1/100; 11 } 12 else { 13 mins=time2%100+60-time1%100; 14 hrs=time2/100-1-time1/100; 15 } 16 System.out.println(hrs+" hrs "+mins+" mins"); 17 } 18 }