分支-12. 计算火车运行时间(15)
2015-01-28 19:19
309 查看
分支-12. 计算火车运行时间(15)
时间限制400 ms内存限制65536 kB代码长度限制8000 B判题程序Standard作者沈睿(浙江大学)本题要求根据火车的出发时间和达到时间,编写程序计算整个旅途所用的时间。输入格式:输入在一行中给出2个4位正整数,其间以空格分隔,分别表示火车的出发时间和到达时间。每个时间的格式为2位小时数(00-23)和2位分钟数(00-59),假设出发和到达在同一天内。输出格式:在一行输出该旅途所用的时间,格式为“hh:mm”,其中hh为2位小时数、mm为2位分钟数。输入样例:1201 1530输出样例:
03:29
import java.util.Scanner;public class Main {public static void main(String[] args) {// TODO Auto-generated method stubScanner in = new Scanner(System.in);int time1 = in.nextInt();int time2 = in.nextInt();int hh = time2/100-time1/100;int mm = time2%100-time1%100;if(mm<0){mm+=60;hh--;}System.out.print(hh>10?hh+":":"0"+hh+":");System.out.print(mm>10?mm:"0"+mm);}}
相关文章推荐
- 分支-12. 计算火车运行时间(15)
- 分支-12. 计算火车运行时间(15)
- 分支-12. 计算火车运行时间(15)
- 分支-12. 计算火车运行时间(15)
- 分支-12. 计算火车运行时间(15)
- 分支-12. 计算火车运行时间(15)*
- 分支-12. 计算火车运行时间(15)
- 分支-12 计算火车运行时间(15)
- 分支-12. 计算火车执行时间(15)
- *分支-12. 计算火车运行时间
- 分支-12. 计算火车运行时间
- 计算火车运行的时间
- 计算火车运行时间(c语言)
- 计算火车运行时间
- 计算程序的运行时间(C++)
- C++中计算程序的运行时间
- 在发电机组控制中累计运行时间的计算
- 计算程序运行时间C#
- VC中计算程序运行时间
- 设计模式里面的深考坝(无废话设计模式)加计算代码运行时间语句