实验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