實驗2-2-9 計算火車運行時間


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));
    }
}

缺少分析,找方法找半天,還不如自己組裝,此題百度過。


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM