AcWing 668. 游戏时间2 - Java
原题链接
中等
作者:
KYCygni
,
2021-03-10 11:46:26
,
所有人可见
,
阅读 285
Java 代码
import java.util.Scanner;
public class Main
{
public static void main(String[] args)
{
Scanner cin = new Scanner(System.in);
int h1 = cin.nextInt();
int m1 = cin.nextInt();
int h2 = cin.nextInt();
int m2 = cin.nextInt();
if (h1 == h2 && m1 == m2)
h2 += 24;
else if (m2 < m1)
{
m2 += 60;
h2 -= 1;
}
if (h2 < h1)
h2 += 24;
System.out.println ("O JOGO DUROU " + (h2 - h1) + " HORA(S) E " + (m2 - m1) + " MINUTO(S)");
}
}